Symptom:
When using XVFB on Travis CI / Gitlab CI for UI testing, creation of a glutin window fails with NoAvailablePixelFormat:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NoAvailablePixelFormat',
Explanation:
This comment is most relevant, but it assumes you know what you're calling Glutin with. If you're using a library, you may not (as was the case with me).
The Travis / Gitlab CI agents do not support multisampling — specifically the GLX_SGI_swap_control GLX extension is not loaded.
In whatever way you're invoking it, you have to turn off multisampling. In Amethyst, you have to set multisamplling: 0 in display_config.ron.
Investigation:
Excerpt from Gitlab CI glxinfo:
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB, GLX_ARB_multisample,
GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,
GLX_EXT_fbconfig_packed_float, GLX_EXT_framebuffer_sRGB,
GLX_EXT_import_context, GLX_EXT_libglvnd, GLX_EXT_texture_from_pixmap,
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer,
GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, GLX_SGI_make_current_read
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_create_context_robustness, GLX_ARB_fbconfig_float,
GLX_ARB_framebuffer_sRGB, GLX_ARB_get_proc_address, GLX_ARB_multisample,
GLX_EXT_buffer_age, GLX_EXT_create_context_es2_profile,
GLX_EXT_create_context_es_profile, GLX_EXT_fbconfig_packed_float,
GLX_EXT_framebuffer_sRGB, GLX_EXT_import_context,
GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating,
GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer,
GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
GLX_MESA_swap_control, GLX_OML_swap_method, GLX_OML_sync_control,
GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer,
GLX_SGIX_visual_select_group, GLX_SGI_make_current_read,
GLX_SGI_swap_control, GLX_SGI_video_sync
GLX version: 1.4
GLX extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB,
GLX_ARB_get_proc_address, GLX_ARB_multisample,
GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,
GLX_EXT_fbconfig_packed_float, GLX_EXT_framebuffer_sRGB,
GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info,
GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer,
GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, GLX_SGI_make_current_read
Excerpt from Travis CI glxinfo, using trusty:
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap,
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer,
GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_SGI_make_current_read
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_create_context_robustness, GLX_ARB_fbconfig_float,
GLX_ARB_framebuffer_sRGB, GLX_ARB_get_proc_address, GLX_ARB_multisample,
GLX_EXT_create_context_es2_profile, GLX_EXT_fbconfig_packed_float,
GLX_EXT_framebuffer_sRGB, GLX_EXT_import_context,
GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating,
GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer,
GLX_MESA_multithread_makecurrent, GLX_MESA_query_renderer,
GLX_MESA_swap_control, GLX_OML_swap_method, GLX_OML_sync_control,
GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer,
GLX_SGIX_visual_select_group, GLX_SGI_make_current_read,
GLX_SGI_swap_control, GLX_SGI_video_sync
GLX version: 1.4
GLX extensions:
GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context,
GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating,
GLX_MESA_copy_sub_buffer, GLX_MESA_multithread_makecurrent,
GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_SGI_make_current_read
See these commit messages and the build statuses next to them to see what I tried. The bottom two green builds are failures — I just read the logs to see if certain GLX extensions were loaded but they weren't.
-
gfx_window_glutinfailed to create a GlWindow, on thisunwrap(): -
Tracing code path:
Potential
Errlocations:-
What is the
gl_attrIt's definitely
GlRequest::Latest:$ rg -F 'GlRequest' amethyst_renderer/src/renderer.rs 278: use glutin::{self, GlProfile, GlRequest}; 284: .with_gl(GlRequest::Latest);-
Looks like it's down to the
choose_fbconfigfunction, which uses the following strings in the extensions:GLX_ARB_create_contextGLX_ARB_create_context_robustnessGLX_ARB_fbconfig_floatGLX_ARB_multisampleGLX_ARB_framebuffer_sRGBGLX_EXT_framebuffer_sRGBGLX_ARB_context_flush_controlGLX_EXT_swap_controlorGLX_SGI_swap_control
My personal computer has all of them, except
GLX_ARB_context_flush_controlandGLX_EXT_swap_controlin all 3 sectionsCI runner's differences from my computer, it only has the following in the Client section (missing from Server and GLX_Extensions sections):
GLX_SGI_swap_controlGLX_ARB_create_context_robustness
So it's looks very likely that one or both extensions need to be in GLX_Extensions.
-
-
finish creating the OpenGL context— ignore, we've determined it's one of the extensions in the earlier point.
From the top answer in What is the relationship between OpenGL, GLX, DRI, and Mesa3D?:
- X provides a windowing system
- GLX is an X extension that provides OpenGL API functions to draw on the window
- There's a server side to GLX, and a client side
- The client side must only call functions that the server side supports (otherwise it doesn't work).
- Mesa is an implementation of the OpenGL standard.
XVFB is the X server. Our XVFB setup has not loaded / does not support GLX_SGI_swap_control or GLX_ARB_create_context_robustness extensions.
-
From source code, it looks like the GL context creation won't fail if
GLX_ARB_create_context_robustnessis not available. -
Can we load the
GLX_SGI_swap_controlextension?This may be updating the Mesa library.-> No. I've updated to Debian Sid which uses Mesa 17.3, and it fails in the same way.Not sure how else the extensions can be loaded. Maybe it's to do with the underlying OS.
-
If not, we may have to disable vsync as it needs
GLX_SGI_swap_control.Tried setting
vsync: falseindisplay_config.ron, it still failed.Tried setting
multisamplling: 0indisplay_config.ron. This worked.orz
Okay that didn't fully solve the problem, but at least I can test my app in CI.