@@ -32,6 +32,7 @@ pub(crate) struct App {
3232 pub ( crate ) control_flow : ControlFlow ,
3333 pub ( crate ) is_visible_before_start : bool ,
3434 pub ( crate ) exit_on_last_window_close : bool ,
35+ pub ( crate ) disable_dma_buf_on_wayland : bool ,
3536 pub ( crate ) webviews : HashMap < WindowId , WebviewInstance > ,
3637 pub ( crate ) float_all : bool ,
3738 pub ( crate ) show_devtools : bool ,
@@ -61,6 +62,7 @@ impl App {
6162
6263 let app = Self {
6364 exit_on_last_window_close : cfg. exit_on_last_window_close ,
65+ disable_dma_buf_on_wayland : cfg. disable_dma_buf_on_wayland ,
6466 is_visible_before_start : true ,
6567 webviews : HashMap :: new ( ) ,
6668 control_flow : ControlFlow :: Wait ,
@@ -101,6 +103,9 @@ impl App {
101103 #[ cfg( any( target_os = "windows" , target_os = "linux" , target_os = "macos" ) ) ]
102104 app. connect_preserve_window_state_handler ( ) ;
103105
106+ // Make sure to disable DMA buffer rendering on Linux Wayland sessions
107+ app. disable_dma_buf ( ) ;
108+
104109 ( event_loop, app)
105110 }
106111
@@ -609,6 +614,28 @@ impl App {
609614 } ) ;
610615 }
611616 }
617+
618+ /// Disable DMA buffer rendering on Linux Wayland sessions to avoid bugs with WebKitGTK
619+ fn disable_dma_buf ( & self ) {
620+ if cfg ! ( target_os = "linux" ) && self . disable_dma_buf_on_wayland {
621+ static INIT : std:: sync:: Once = std:: sync:: Once :: new ( ) ;
622+ INIT . call_once ( || {
623+ if std:: path:: Path :: new ( "/dev/dri" ) . exists ( )
624+ && std:: env:: var ( "XDG_SESSION_TYPE" ) . unwrap_or_default ( ) == "wayland"
625+ {
626+ // Gnome Webkit is currently buggy under Wayland and KDE, so we will run it with XWayland mode.
627+ // See: https://github.com/DioxusLabs/dioxus/issues/3667
628+ unsafe {
629+ // Disable explicit sync for NVIDIA drivers on Linux when using Way
630+ std:: env:: set_var ( "WEBKIT_DISABLE_DMABUF_RENDERER" , "1" ) ;
631+ }
632+ }
633+ unsafe {
634+ std:: env:: set_var ( "GDK_BACKEND" , "x11" ) ;
635+ }
636+ } ) ;
637+ }
638+ }
612639}
613640
614641#[ derive( Debug , serde:: Serialize , serde:: Deserialize ) ]
0 commit comments