Fix EGL_BAD_MATCH crash on X11 by pre-picking a GL-compatible visual#57
Open
tonybierman wants to merge 3 commits intoDioxusLabs:mainfrom
Open
Fix EGL_BAD_MATCH crash on X11 by pre-picking a GL-compatible visual#57tonybierman wants to merge 3 commits intoDioxusLabs:mainfrom
tonybierman wants to merge 3 commits intoDioxusLabs:mainfrom
Conversation
…AD_MATCH winit's default X11 window inherits the root visual via COPY_FROM_PARENT, which may not match any EGL FBConfig. The Skia OpenGL backend then panics with `EGL_BAD_MATCH` at `eglCreateWindowSurface` (e.g. on NVIDIA + X11). Expose `pick_x11_gl_visual` so callers can query a GL-compatible visual from the EGL configs and apply it via `WindowAttributesExtX11::with_x11_visual` before creating the window. The `OpenGLBackend` config search now also filters with `compatible_with_native_window` so it converges on the same visual. Update bunnymark to use the new helper so its default Skia/GL path no longer crashes on startup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Same fix as bunnymark — the player's default Skia/GL backend would crash at startup on X11 because winit's COPY_FROM_PARENT visual may not match any EGL config. Apply `pick_x11_gl_visual` before window creation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Address review nits from the prior commit:
- pick_gl_config now returns Option<Config> so pick_x11_gl_visual can
honor its documented Option<u32> contract instead of panicking when
no EGL configs are available. OpenGLBackend::new keeps a clear panic
at its call site.
- Cache the glutin Display in a process-local OnceLock<Mutex<HashMap>>
keyed by raw display pointer so we don't initialize EGL twice for the
same X server connection (once in pick_x11_gl_visual, once in
OpenGLBackend::new).
- Reword the docstring to match the cfg gating: macOS/Windows callers
can't see the symbol, so describe failure modes by display-handle
variant ("non-Xlib/Xcb display handles") instead.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
@nicoburns request review. Two of the examples panic on X11; this PR should fix them without side effects. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Linux/X11, winit creates windows with
COPY_FROM_PARENTfor the visual, which may not have any matching EGL FBConfig and causesSkiaWindowRenderer's OpenGL backend to panic withEGL_BAD_MATCHateglCreateWindowSurface(reproduced on NVIDIA + X11). This PR adds a publicanyrender_skia::pick_x11_gl_visualhelper that queries a compatible visual from the EGL configs so callers can apply it viaWindowAttributesExtX11::with_x11_visualbefore window creation, and updates thebunnymarkandplayerexamples to use it.🤖 Generated with Claude Code