From ebbaf3fb784c6afa5244bde9f9e3d06fb4d7c703 Mon Sep 17 00:00:00 2001 From: Elie Habib Date: Fri, 27 Feb 2026 00:19:35 +0400 Subject: [PATCH] fix(linux): detect NVIDIA GPU and work around EGL_BAD_ALLOC on Wayland Linux users with NVIDIA proprietary drivers on Wayland report crashes: "Could not create surfaceless EGL display: EGL_BAD_ALLOC. Aborting..." WebKitGTK's web process calls eglGetPlatformDisplay with the EGL_PLATFORM_SURFACELESS_MESA platform, which fails with NVIDIA's EGL implementation and triggers abort(). WEBKIT_DISABLE_DMABUF_RENDERER=1 (already set) only controls buffer sharing, not EGL initialization. Detect NVIDIA via /proc/driver/nvidia and: - Set __NV_DISABLE_EXPLICIT_SYNC=1 to prevent Wayland flickering - Force GDK_BACKEND=x11 on NVIDIA+Wayland (user can override) Also bumps version to 2.5.19. Refs: tauri-apps/tauri#9394, gitbutlerapp/gitbutler#5282 --- package.json | 3 ++- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/src/main.rs | 22 ++++++++++++++++++++++ src-tauri/tauri.conf.json | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index aad166075..bf04cc27f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "world-monitor", "private": true, - "version": "2.5.18", + "version": "2.5.19", "license": "AGPL-3.0-only", "type": "module", "scripts": { @@ -28,6 +28,7 @@ "test:e2e:runtime": "VITE_VARIANT=full playwright test e2e/runtime-fetch.spec.ts", "test:e2e": "npm run test:e2e:runtime && npm run test:e2e:full && npm run test:e2e:tech && npm run test:e2e:finance", "test:data": "node --test tests/*.test.mjs", + "test:feeds": "node scripts/validate-rss-feeds.mjs", "test:sidecar": "node --test src-tauri/sidecar/local-api-server.test.mjs api/_cors.test.mjs api/youtube/embed.test.mjs api/cyber-threats.test.mjs api/usni-fleet.test.mjs scripts/ais-relay-rss.test.cjs api/loaders-xml-wms-regression.test.mjs", "test:e2e:visual:full": "VITE_VARIANT=full playwright test -g \"matches golden screenshots per layer and zoom\"", "test:e2e:visual:tech": "VITE_VARIANT=tech playwright test -g \"matches golden screenshots per layer and zoom\"", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 391bea8c9..143815261 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -5423,7 +5423,7 @@ dependencies = [ [[package]] name = "world-monitor" -version = "2.5.15" +version = "2.5.19" dependencies = [ "getrandom 0.2.17", "keyring", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 5381c45bd..8bfa0fc05 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "world-monitor" -version = "2.5.18" +version = "2.5.19" description = "World Monitor desktop application" authors = ["World Monitor"] edition = "2021" diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 816476fc3..bee34846b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1163,6 +1163,28 @@ fn main() { eprintln!("[tauri] VM detected; disabled WebKitGTK accelerated compositing for iframe/video compatibility"); } + // NVIDIA proprietary drivers often fail to create a surfaceless EGL + // display (EGL_BAD_ALLOC) in WebKitGTK's web process, especially on + // Wayland where explicit sync can also cause flickering/crashes. + // Detect NVIDIA by checking for /proc/driver/nvidia (created by + // nvidia.ko) and apply Wayland-specific workarounds. + let has_nvidia = std::path::Path::new("/proc/driver/nvidia").exists(); + if has_nvidia { + if env::var_os("__NV_DISABLE_EXPLICIT_SYNC").is_none() { + unsafe { env::set_var("__NV_DISABLE_EXPLICIT_SYNC", "1") }; + } + // Force X11 backend on NVIDIA + Wayland to avoid surfaceless EGL + // failures. Users who prefer native Wayland can override with + // GDK_BACKEND=wayland. + if env::var_os("WAYLAND_DISPLAY").is_some() && env::var_os("GDK_BACKEND").is_none() { + unsafe { env::set_var("GDK_BACKEND", "x11") }; + eprintln!( + "[tauri] NVIDIA GPU + Wayland detected; forcing GDK_BACKEND=x11 to avoid EGL_BAD_ALLOC. \ + Set GDK_BACKEND=wayland to override." + ); + } + } + // On Wayland-only compositors (e.g. niri, river, sway without XWayland), // GTK3 may fail to initialise if it defaults to X11 backend first and no // DISPLAY is set. Explicitly prefer the Wayland backend when a Wayland diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index e692b05f0..77ed5f539 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -2,7 +2,7 @@ "$schema": "https://schema.tauri.app/config/2", "productName": "World Monitor", "mainBinaryName": "world-monitor", - "version": "2.5.18", + "version": "2.5.19", "identifier": "app.worldmonitor.desktop", "build": { "beforeDevCommand": "npm run build:sidecar-sebuf && npm run dev",