From 22055d15e4b61ed8b0b28e2d38a684077f7f27d9 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 8 Feb 2026 18:57:22 -0600 Subject: [PATCH] fix(appimage): force X11 backend on Wayland to prevent EGL crash WEBKIT_DISABLE_DMABUF_RENDERER alone is not enough: WebKitGTK's Wayland platform init calls eglGetPlatformDisplay() in PlatformDisplayWayland before any renderer decision, and the AppImage's bundled EGL loader is incompatible with the host Mesa/driver, causing EGL_BAD_PARAMETER abort. Force GDK_BACKEND=x11 for AppImage + Wayland so WebKitGTK uses GLX via XWayland instead of EGL, bypassing the crash entirely. Users who want native Wayland can override with GDK_BACKEND=wayland. Non-AppImage builds (Flatpak, RPM, DEB) are unaffected and continue using native Wayland. cc --- src-tauri/src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 07b3ae519..757b4d1c3 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -178,11 +178,23 @@ fn main() { } // --- GDK backend selection --- + // AppImage + Wayland: force X11 (XWayland) to prevent EGL crash. + // WebKitGTK's Wayland platform init calls eglGetPlatformDisplay() which + // fails with EGL_BAD_PARAMETER when the AppImage bundles an EGL loader + // incompatible with the host's Mesa/driver. Neither LIBGL_ALWAYS_SOFTWARE + // nor WEBKIT_DISABLE_DMABUF_RENDERER prevent this — the call happens in + // PlatformDisplayWayland before any renderer decision. + // X11 via XWayland uses GLX instead of EGL, avoiding the crash entirely. + // Users who want native Wayland can override with GDK_BACKEND=wayland. if force_x11 && is_wayland { qbz_nix_lib::logging::log_startup("[QBZ] User override: Forcing X11 backend (QBZ_FORCE_X11=1)"); std::env::set_var("GDK_BACKEND", "x11"); + } else if is_wayland && is_appimage && std::env::var_os("GDK_BACKEND").is_none() { + qbz_nix_lib::logging::log_startup("[QBZ] AppImage on Wayland: using X11 backend (XWayland) to prevent EGL crash"); + qbz_nix_lib::logging::log_startup("[QBZ] To force native Wayland: set GDK_BACKEND=wayland"); + std::env::set_var("GDK_BACKEND", "x11"); } else if is_wayland && std::env::var_os("GDK_BACKEND").is_none() { - // Force Wayland backend to avoid fallback issues + // Non-AppImage Wayland: use native Wayland backend std::env::set_var("GDK_BACKEND", "wayland"); // Prefer client-side decorations (we use custom titlebar anyway)