From aa5a9006ab88775b9053e81a0bce2c3b82646965 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 31 Aug 2026 03:20:22 +0000 Subject: [PATCH 1/4] Initial plan From 21760c9568620b3e35197b122d389f06cb75df50 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 31 Aug 2026 03:22:41 +0000 Subject: [PATCH 2/4] fix(linux): fall back to X11 for Wayland AppImage Co-authored-by: zouyonghe <62183434+zouyonghe@users.noreply.github.com> --- src-tauri/src/app_runtime.rs | 47 +++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/app_runtime.rs b/src-tauri/src/app_runtime.rs index 0894b5c3..6798e7d6 100644 --- a/src-tauri/src/app_runtime.rs +++ b/src-tauri/src/app_runtime.rs @@ -5,9 +5,19 @@ use tauri::{ #[cfg(target_os = "linux")] mod linux_webkit_workaround { + const APPIMAGE_ENV: &str = "APPIMAGE"; + const GDK_BACKEND_ENV: &str = "GDK_BACKEND"; const WEBKIT_DISABLE_DMABUF_RENDERER_ENV: &str = "WEBKIT_DISABLE_DMABUF_RENDERER"; const WAYLAND_DISPLAY_ENV: &str = "WAYLAND_DISPLAY"; + fn should_set_gdk_backend_env( + existing_value: Option<&std::ffi::OsStr>, + wayland_display: Option<&std::ffi::OsStr>, + appimage: Option<&std::ffi::OsStr>, + ) -> bool { + existing_value.is_none() && wayland_display.is_some() && appimage.is_some() + } + fn should_set_webkit_dmabuf_renderer_env( existing_value: Option<&std::ffi::OsStr>, wayland_display: Option<&std::ffi::OsStr>, @@ -16,6 +26,17 @@ mod linux_webkit_workaround { } pub(super) fn configure(log: impl Fn(&str)) { + if should_set_gdk_backend_env( + std::env::var_os(GDK_BACKEND_ENV).as_deref(), + std::env::var_os(WAYLAND_DISPLAY_ENV).as_deref(), + std::env::var_os(APPIMAGE_ENV).as_deref(), + ) { + std::env::set_var(GDK_BACKEND_ENV, "x11"); + log(&format!( + "applied Linux AppImage WebKit workaround: set {GDK_BACKEND_ENV}=x11" + )); + } + if should_set_webkit_dmabuf_renderer_env( std::env::var_os(WEBKIT_DISABLE_DMABUF_RENDERER_ENV).as_deref(), std::env::var_os(WAYLAND_DISPLAY_ENV).as_deref(), @@ -29,7 +50,31 @@ mod linux_webkit_workaround { #[cfg(test)] mod tests { - use super::should_set_webkit_dmabuf_renderer_env; + use super::{should_set_gdk_backend_env, should_set_webkit_dmabuf_renderer_env}; + + #[test] + fn appimage_wayland_workaround_uses_x11_unless_overridden() { + assert!(should_set_gdk_backend_env( + None, + Some(std::ffi::OsStr::new("wayland-0")), + Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")) + )); + assert!(!should_set_gdk_backend_env( + Some(std::ffi::OsStr::new("wayland")), + Some(std::ffi::OsStr::new("wayland-0")), + Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")) + )); + assert!(!should_set_gdk_backend_env( + None, + None, + Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")) + )); + assert!(!should_set_gdk_backend_env( + None, + Some(std::ffi::OsStr::new("wayland-0")), + None + )); + } #[test] fn webkit_dmabuf_workaround_is_set_only_for_wayland_without_override() { From d844bb65a32570ecd2be453110ad521b3e05d566 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 31 Aug 2026 03:23:08 +0000 Subject: [PATCH 3/4] fix(linux): configure WebKit before runtime startup Co-authored-by: zouyonghe <62183434+zouyonghe@users.noreply.github.com> --- src-tauri/src/app_runtime.rs | 6 ++++-- src-tauri/src/main.rs | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/app_runtime.rs b/src-tauri/src/app_runtime.rs index 6798e7d6..ad205627 100644 --- a/src-tauri/src/app_runtime.rs +++ b/src-tauri/src/app_runtime.rs @@ -270,10 +270,12 @@ fn handle_run_event(app_handle: &tauri::AppHandle, event: RunEvent) { } } -pub(crate) fn run() { - #[cfg(target_os = "linux")] +#[cfg(target_os = "linux")] +pub(crate) fn configure_linux_webkit_workaround() { linux_webkit_workaround::configure(append_startup_log); +} +pub(crate) fn run() { append_startup_log("desktop process starting"); append_startup_log(&format!( "desktop log path: {}", diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 4e90c999..15cc5b4b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -45,5 +45,8 @@ pub(crate) use app_types::{ pub(crate) use desktop_settings::DesktopSettingsCache; fn main() { + #[cfg(target_os = "linux")] + app_runtime::configure_linux_webkit_workaround(); + app_runtime::run(); } From 862ca0ee783c32b17ce403dbeafd4fa9e2a7ccf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=B0=B8=E8=B5=AB?= <1259085392@qq.com> Date: Tue, 1 Sep 2026 08:58:25 +0900 Subject: [PATCH 4/4] fix(linux): detect APPDIR AppImage launches --- src-tauri/src/app_runtime.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/app_runtime.rs b/src-tauri/src/app_runtime.rs index ad205627..3d35179e 100644 --- a/src-tauri/src/app_runtime.rs +++ b/src-tauri/src/app_runtime.rs @@ -6,6 +6,7 @@ use tauri::{ #[cfg(target_os = "linux")] mod linux_webkit_workaround { const APPIMAGE_ENV: &str = "APPIMAGE"; + const APPDIR_ENV: &str = "APPDIR"; const GDK_BACKEND_ENV: &str = "GDK_BACKEND"; const WEBKIT_DISABLE_DMABUF_RENDERER_ENV: &str = "WEBKIT_DISABLE_DMABUF_RENDERER"; const WAYLAND_DISPLAY_ENV: &str = "WAYLAND_DISPLAY"; @@ -14,8 +15,11 @@ mod linux_webkit_workaround { existing_value: Option<&std::ffi::OsStr>, wayland_display: Option<&std::ffi::OsStr>, appimage: Option<&std::ffi::OsStr>, + appdir: Option<&std::ffi::OsStr>, ) -> bool { - existing_value.is_none() && wayland_display.is_some() && appimage.is_some() + existing_value.is_none() + && wayland_display.is_some() + && (appimage.is_some() || appdir.is_some()) } fn should_set_webkit_dmabuf_renderer_env( @@ -30,6 +34,7 @@ mod linux_webkit_workaround { std::env::var_os(GDK_BACKEND_ENV).as_deref(), std::env::var_os(WAYLAND_DISPLAY_ENV).as_deref(), std::env::var_os(APPIMAGE_ENV).as_deref(), + std::env::var_os(APPDIR_ENV).as_deref(), ) { std::env::set_var(GDK_BACKEND_ENV, "x11"); log(&format!( @@ -57,21 +62,31 @@ mod linux_webkit_workaround { assert!(should_set_gdk_backend_env( None, Some(std::ffi::OsStr::new("wayland-0")), - Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")) + Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")), + None + )); + assert!(should_set_gdk_backend_env( + None, + Some(std::ffi::OsStr::new("wayland-0")), + None, + Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot")) )); assert!(!should_set_gdk_backend_env( Some(std::ffi::OsStr::new("wayland")), Some(std::ffi::OsStr::new("wayland-0")), - Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")) + Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")), + None )); assert!(!should_set_gdk_backend_env( None, None, - Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")) + Some(std::ffi::OsStr::new("/tmp/.mount_AstrBot/AppRun")), + None )); assert!(!should_set_gdk_backend_env( None, Some(std::ffi::OsStr::new("wayland-0")), + None, None )); }