From 7fc2abea0121417f4eabbff34c4c0ca760024aff Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 11 Nov 2025 13:09:48 -0300 Subject: [PATCH 1/2] disable dma buf on linux --- packages/desktop/src/app.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/desktop/src/app.rs b/packages/desktop/src/app.rs index 596c0d808c..54d9d9a401 100644 --- a/packages/desktop/src/app.rs +++ b/packages/desktop/src/app.rs @@ -102,6 +102,9 @@ impl App { #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))] app.connect_preserve_window_state_handler(); + // Make sure to disable DMA buffer rendering on Linux Wayland sessions + app.disable_dma_buf(); + (event_loop, app) } @@ -618,6 +621,28 @@ impl App { }); } } + + /// Disable DMA buffer rendering on Linux Wayland sessions to avoid bugs with WebKitGTK + fn disable_dma_buf(&self) { + if cfg!(target_os = "linux") { + static INIT: std::sync::Once = std::sync::Once::new(); + INIT.call_once(|| { + if std::path::Path::new("/dev/dri").exists() + && std::env::var("XDG_SESSION_TYPE").unwrap_or_default() == "wayland" + { + // Gnome Webkit is currently buggy under Wayland and KDE, so we will run it with XWayland mode. + // See: https://github.com/DioxusLabs/dioxus/issues/3667 + unsafe { + // Disable explicit sync for NVIDIA drivers on Linux when using Way + std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1"); + } + } + unsafe { + std::env::set_var("GDK_BACKEND", "x11"); + } + }); + } + } } #[derive(Debug, serde::Serialize, serde::Deserialize)] From e7bd415d54c0221baa561f4f9c276ea2143d202a Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 11 Nov 2025 13:14:00 -0300 Subject: [PATCH 2/2] allow configuring --- packages/desktop/src/app.rs | 4 +++- packages/desktop/src/config.rs | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/desktop/src/app.rs b/packages/desktop/src/app.rs index 54d9d9a401..3e52c849d4 100644 --- a/packages/desktop/src/app.rs +++ b/packages/desktop/src/app.rs @@ -33,6 +33,7 @@ pub(crate) struct App { pub(crate) control_flow: ControlFlow, pub(crate) is_visible_before_start: bool, pub(crate) exit_on_last_window_close: bool, + pub(crate) disable_dma_buf_on_wayland: bool, pub(crate) webviews: HashMap, pub(crate) float_all: bool, pub(crate) show_devtools: bool, @@ -62,6 +63,7 @@ impl App { let app = Self { exit_on_last_window_close: cfg.exit_on_last_window_close, + disable_dma_buf_on_wayland: cfg.disable_dma_buf_on_wayland, is_visible_before_start: true, webviews: HashMap::new(), control_flow: ControlFlow::Wait, @@ -624,7 +626,7 @@ impl App { /// Disable DMA buffer rendering on Linux Wayland sessions to avoid bugs with WebKitGTK fn disable_dma_buf(&self) { - if cfg!(target_os = "linux") { + if cfg!(target_os = "linux") && self.disable_dma_buf_on_wayland { static INIT: std::sync::Once = std::sync::Once::new(); INIT.call_once(|| { if std::path::Path::new("/dev/dri").exists() diff --git a/packages/desktop/src/config.rs b/packages/desktop/src/config.rs index b09323e3e7..6a58964e45 100644 --- a/packages/desktop/src/config.rs +++ b/packages/desktop/src/config.rs @@ -67,6 +67,7 @@ pub struct Config { pub(crate) window_close_behavior: WindowCloseBehaviour, pub(crate) custom_event_handler: Option, pub(crate) disable_file_drop_handler: bool, + pub(crate) disable_dma_buf_on_wayland: bool, #[allow(clippy::type_complexity)] pub(crate) on_window: Option, &mut VirtualDom) + 'static>>, @@ -117,6 +118,7 @@ impl Config { window_close_behavior: WindowCloseBehaviour::WindowCloses, custom_event_handler: None, disable_file_drop_handler: false, + disable_dma_buf_on_wayland: true, on_window: None, } } @@ -312,6 +314,15 @@ impl Config { self.on_window = Some(Box::new(f)); self } + + /// Set whether or not DMA-BUF usage should be disabled on Wayland. + /// + /// Defaults to true to avoid issues on some systems. If you want to enable DMA-BUF usage, set this to false. + /// See + pub fn with_disable_dma_buf_on_wayland(mut self, disable: bool) -> Self { + self.disable_dma_buf_on_wayland = disable; + self + } } impl Default for Config {