feat(linux): auto-configure WebKit env for NVIDIA+Wayland at startup - #300
Conversation
WebKitGTK rendering fails on the NVIDIA + Wayland combination (blank windows, 'Error 71' protocol errors), forcing users to manually export GDK_BACKEND=x11 and WEBKIT_DISABLE_COMPOSITING_MODE=1. Detect that combo in main() before any webview is created and set those variables automatically, respecting pre-set values. Following the Tauri-documented pattern (v2.tauri.app/develop/debug/linux-graphics), this covers all Linux dist formats at once instead of per-format packaging hooks.
|
Note that there is an extended tauri plugin at https://github.com/hrzlgnm/webkit2gtk-nvidia-quirk that might better cover Wayland+Nvidia tauri rendering. In my case, Kwin/Plasma isn't yet handled. |
|
Hi @nvandamme, Thank you for tackling the notorious WebKitGTK + NVIDIA + Wayland rendering issue! It's a well-known pain point on Linux desktop setups. While automatic workarounds are very helpful, there are a few important architectural points and regressions we should address before merging this: 1. Avoid forcing
|
|
By the way, I checked the repository you shared ( Interestingly, that crate validates the exact concern regarding WEBKIT_DISABLE_DMABUF_RENDERER=1The reason you likely ran into issues on KWin/Plasma is that KWin often requires disabling compositing mode alongside the DMABUF renderer: if std::env::var("WEBKIT_DISABLE_DMABUF_RENDERER").is_err() {
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
}
if std::env::var("WEBKIT_DISABLE_COMPOSITING_MODE").is_err() {
std::env::set_var("WEBKIT_DISABLE_COMPOSITING_MODE", "1");
}Combining these two environment variables addresses the crash on KWin/Plasma, Hyprland, and GNOME alike, while keeping the window running natively on Wayland without needing We don't need to pull in an external crate dependency either; handling the lightweight GPU detection natively inside |
|
added a PR about Kwin/plasma on the mentioned plugin : hint: it works with __NV_DISABLE_EXPLICIT_SYNC=1 under Kwin+Nvidia while allowing wayland i'll try with yours and report back |
Per maintainer feedback: - Use WEBKIT_DISABLE_DMABUF_RENDERER + WEBKIT_DISABLE_COMPOSITING_MODE instead of forcing GDK_BACKEND=x11, keeping native Wayland/X11 backends - Scope to NVIDIA GPUs only so Mesa users keep their default rendering path - Move detection/setup into utils/app/platform.rs::apply_linux_graphics_quirks() with unit tests; lib.rs keeps only the gated call - Gate with cfg(all(desktop, linux, not(web-server))) so headless builds skip it Verified end-to-end on NVIDIA + KDE Plasma Wayland: zero protocol errors, GDK_BACKEND preserved, env vars auto-set.
Hakanbaban53
left a comment
There was a problem hiding this comment.
Looks fantastic now! Thank you for addressing all the feedback so quickly and adding thorough unit tests.
Retaining native Wayland without forcing XWayland while keeping the logic cleanly encapsulated in platform.rs ensures great rendering across all Linux environments and packaging formats (including Flatpak).
LGTM! 🚀
One refinement I kept: scoping to NVIDIA GPUs (/proc/driver/nvidia/version or PCI vendor 0x10de). The rendering bugs seems specific to the NVIDIA EGL stack: on Mesa (Intel/AMD) the DMA-BUF renderer works fine, so disabling it there would regress their path without fixing anything. |
Problem
WebKitGTK rendering fails on the NVIDIA + Wayland combination (blank windows,
Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display),forcing users to manually export
GDK_BACKEND=x11andWEBKIT_DISABLE_COMPOSITING_MODE=1before launching.Solution
Detect that combination in
main()before any webview is created and set thosevariables automatically, respecting pre-set values. This follows the Tauri-
documented pattern (https://v2.tauri.app/develop/debug/linux-graphics) and
covers all Linux dist formats at once instead of per-format packaging hooks.
Verification
Verified end-to-end on an NVIDIA + KDE Plasma Wayland workstation: