From 6354cb42b28e38d571fed19ecfbf7a0c83c75571 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Thu, 27 Aug 2026 10:45:24 -0700 Subject: [PATCH] Work around WebKitGTK's EGL crash on Wayland (triple-c#34) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported on CachyOS/Arch with Wayland: the app aborts immediately with "Could not create default EGL display: EGL_BAD_PARAMETER. Aborting." printed straight to stderr by WebKitGTK's own C code, before Triple-C's own logging even gets a chance to say anything useful about it. This is WebKitGTK's DMA-BUF renderer (its default accelerated-compositing path since 2.42) failing on some Mesa/driver/compositor combinations. Set WEBKIT_DISABLE_DMABUF_RENDERER=1 unconditionally on Linux before the Tauri builder runs, which is where GTK/WebKitGTK actually read it — there's no reliable way to detect the affected combination ahead of time (reports of this exact failure exist under XWayland too, not just pure Wayland sessions), and WebKitGTK's fallback compositing path costs some rendering performance this app's UI doesn't need. Left alone if a user has already set the variable themselves. Does not address the other two things filed under the same issue (links not opening on the host, and a request for a native Arch/CachyOS package) — those need more information / are a separate scope, respectively. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FGjXq6fqtAFHdbhk4f3PfZ --- app/src-tauri/src/main.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/src-tauri/src/main.rs b/app/src-tauri/src/main.rs index b76dde6..cff911e 100644 --- a/app/src-tauri/src/main.rs +++ b/app/src-tauri/src/main.rs @@ -1,6 +1,35 @@ // Prevents additional console window on Windows in release #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +/// WebKitGTK's DMA-BUF renderer (its default accelerated-compositing path +/// since 2.42) fails outright on some Mesa/driver/compositor combinations +/// under Wayland, printing `Could not create default EGL display: +/// EGL_BAD_PARAMETER. Aborting.` straight to stderr from WebKitGTK's own C +/// code and killing the webview before Triple-C's own logging even starts — +/// see triple-c#34, reported on CachyOS/Arch with Wayland. There is no +/// reliable way to detect the affected driver/compositor combination ahead +/// of time (it is not simply "Wayland vs. X11" — the same failure has been +/// reported under XWayland too), so this is set unconditionally on Linux +/// rather than gated on `WAYLAND_DISPLAY`. WebKitGTK falls back to a +/// software/shared-memory compositing path when this is set, which costs +/// some rendering performance but nothing this app's UI depends on. +/// +/// Must be set before `triple_c_lib::run()` — GTK/WebKitGTK reads it at +/// their own init time, which happens inside the Tauri builder that +/// function calls into, not at binary load. +/// +/// A user who has already set this themselves (including to `0`, to force +/// the DMA-BUF path back on for their own hardware) is left alone. +#[cfg(target_os = "linux")] +fn apply_webkit_wayland_workaround() { + if std::env::var_os("WEBKIT_DISABLE_DMABUF_RENDERER").is_none() { + std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1"); + } +} + fn main() { + #[cfg(target_os = "linux")] + apply_webkit_wayland_workaround(); + triple_c_lib::run() }