Skip to content

Fix startup crash on Linux Wayland by falling back to XWayland (xcb)#39

Open
hongquanli wants to merge 1 commit into
mainfrom
fix/wayland-xcb-fallback
Open

Fix startup crash on Linux Wayland by falling back to XWayland (xcb)#39
hongquanli wants to merge 1 commit into
mainfrom
fix/wayland-xcb-fallback

Conversation

@hongquanli

Copy link
Copy Markdown
Collaborator

Problem

On a native Wayland session (Ubuntu, WAYLAND_DISPLAY set), ndviewer-light crashes immediately on launch. The dataset loads fine, but PyQt5 + vispy (OpenGL) cannot create an EGL surface:

The Wayland connection experienced a fatal error: Invalid argument
Could not create EGL surface (EGL error 0x3000)
QOpenGLWidget: Failed to make context current

Fix

In main(), before constructing QApplication, default QT_QPA_PLATFORM to xcb (XWayland) when:

  • the platform is Linux, and
  • the session is Wayland (WAYLAND_DISPLAY is set), and
  • the user hasn't already chosen a Qt platform (QT_QPA_PLATFORM unset).

XWayland renders reliably for this vispy/PyQt5 stack. X11 sessions and explicit user overrides are left untouched.

Testing

On the affected Wayland machine:

  • Before: crashes on launch with the EGL errors above.
  • After: launches and runs cleanly, no EGL/Wayland errors — verified opening a 5-channel, 83-FOV OME-TIFF acquisition ((t=1, fov=83, z=1, c=5, 4168×4168)).

🤖 Generated with Claude Code

On native Wayland sessions, PyQt5 + vispy (OpenGL) fails to create an
EGL surface, so the viewer crashes immediately on launch:

  The Wayland connection experienced a fatal error: Invalid argument
  Could not create EGL surface (EGL error 0x3000)
  QOpenGLWidget: Failed to make context current

Default QT_QPA_PLATFORM to "xcb" (XWayland) when running on Linux under
Wayland, unless the user has already set a Qt platform. XWayland renders
reliably and this leaves X11 sessions and explicit overrides untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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