Skip to content

Fix EGL_BAD_MATCH crash on X11 by pre-picking a GL-compatible visual#57

Open
tonybierman wants to merge 3 commits intoDioxusLabs:mainfrom
tonybierman:fix/skia-x11-egl-bad-match
Open

Fix EGL_BAD_MATCH crash on X11 by pre-picking a GL-compatible visual#57
tonybierman wants to merge 3 commits intoDioxusLabs:mainfrom
tonybierman:fix/skia-x11-egl-bad-match

Conversation

@tonybierman
Copy link
Copy Markdown

On Linux/X11, winit creates windows with COPY_FROM_PARENT for the visual, which may not have any matching EGL FBConfig and causes SkiaWindowRenderer's OpenGL backend to panic with EGL_BAD_MATCH at eglCreateWindowSurface (reproduced on NVIDIA + X11). This PR adds a public anyrender_skia::pick_x11_gl_visual helper that queries a compatible visual from the EGL configs so callers can apply it via WindowAttributesExtX11::with_x11_visual before window creation, and updates the bunnymark and player examples to use it.

🤖 Generated with Claude Code

tonybierman and others added 3 commits May 8, 2026 08:27
…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>
@tonybierman
Copy link
Copy Markdown
Author

tonybierman commented May 8, 2026

@nicoburns request review. Two of the examples panic on X11; this PR should fix them without side effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant