Skip to content

Commit e6e2d31

Browse files
committed
🐛 Plotting: fix XCrySDen OpenGL initialisation in VMs
XCrySDen fails to start in VirtualBox VMs with the error "Couldn't configure togl widget". The root cause is that XCrySDen requests an OpenGL accumulation buffer by default, which is not supported by virtual GPUs (SVGA3D, llvmpipe). This causes the togl widget to fail during context creation, even when GLX and Mesa are properly set up. The fix is to disable the accumulation buffer in XCrySDen's custom-definitions file by setting `toglOpt(accum)` to false. This is done automatically during provisioning by copying the default custom-definitions file to `~/.xcrysden/` and patching the relevant line with `lineinfile`. Note that this issue does not affect bare-metal installations, where real GPUs support the accumulation buffer without issue.
1 parent c463929 commit e6e2d31

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

local/tasks/plotting-tools.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,31 @@
1111
name: "{{ packages | join(' ') }}"
1212
register: plot_versions
1313

14+
- name: "Configure XCrySDen for virtual machine compatibility"
15+
# XCrySDen requests an OpenGL accumulation buffer by default, which is not
16+
# supported by virtual GPUs (SVGA3D, llvmpipe). Disabling it allows the togl
17+
# widget to initialize successfully in a VM.
18+
when: "'xcrysden' in packages"
19+
become: true
20+
become_user: "{{ vm_user }}"
21+
block:
22+
- name: "Create ~/.xcrysden directory"
23+
ansible.builtin.file:
24+
path: "/home/{{ vm_user }}/.xcrysden"
25+
state: directory
26+
mode: "0755"
27+
- name: "Copy custom-definitions"
28+
ansible.builtin.copy:
29+
src: /usr/share/xcrysden/Tcl/custom-definitions
30+
dest: "/home/{{ vm_user }}/.xcrysden/custom-definitions"
31+
remote_src: true
32+
mode: "0644"
33+
- name: "Disable accumulation buffer"
34+
ansible.builtin.lineinfile:
35+
path: "/home/{{ vm_user }}/.xcrysden/custom-definitions"
36+
regexp: '.*set toglOpt\(accum\).*'
37+
line: "set toglOpt(accum) false"
38+
1439
- name: "Document versions"
1540
loop: "{{ plot_versions.data | dict2items }}"
1641
loop_control:

0 commit comments

Comments
 (0)