Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(linux): 丢弃 AppImage 钩子强制的 GDK_BACKEND=x11,修复 Wayland 下点击后停绘(#789) (#791)

Mao Mr9ffa89c55b01
diff --git a/README.en.md b/README.en.md
index a08c026b..373464cd 100644
--- a/README.en.md
+++ b/README.en.md
@@ -94,7 +94,7 @@ The first run downloads the Node runtime and Harness core (if `dsh` is already i
**Offline bundle (Windows / macOS / Linux):** Releases also ship `Deepseek.Harness.Desktop_Bundle_<version>.<ext>` — the Node runtime and Harness core are bundled in, so the **first launch needs no network**. Built for air-gapped / whitelisted machines (preset and community plugins still need network, and git-backed features such as worktree need a system Git). The Linux bundle ships inside the `.deb`, whose `/usr/lib` resources are read-only, so the bundled core's directory permissions have to be fixed after a root install.
-> **Linux Wayland note (PikaOS / GNOME Wayland / Ubuntu 22.04+):** AppImage may crash or render black on Wayland due to WebKitGTK; the app auto-fixes the common case. <details><summary>If it still crashes / renders black:</summary><br>**Prefer `.deb`** (verified on PikaOS 4 Wayland), or manually run `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`. If icons do not appear, copy the app's `hicolor` icons to `~/.local/share/icons` and run `update-desktop-database`.<br></details>
+> **Linux Wayland note (PikaOS / GNOME Wayland / Ubuntu 22.04+):** the AppImage's GTK hook forces `GDK_BACKEND=x11`; when a Wayland session is available the app drops it and uses the native Wayland backend instead (issue #789), while the WebKitGTK black-screen/crash fallback still applies. <details><summary>If it still crashes / renders black, or you need the pet window on top:</summary><br>**Prefer `.deb`** (verified on PikaOS 4 Wayland); to keep XWayland set `DSH_FORCE_XWAYLAND=1` (or enable `force_xwayland` in settings); rendering fallback `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 ./AppImage`. If icons do not appear, copy the app's `hicolor` icons to `~/.local/share/icons` and run `update-desktop-database`.<br></details>
>
> **Rolling-release Linux starts and dies at once (Arch / CachyOS / Fedora, …):** older AppImages bundled the build image's (Ubuntu 22.04) display-stack libs such as `libwayland-client`. A newer host Mesa is ABI-incompatible with them, so `WebKitWebProcess` calls `abort()` — the app shows **no window and no logs at all**. The build now strips these libs (see `.github/workflows/build-linux.yml` and `scripts/fix-appimage-host-libs.sh`); use a release built after that change. If you are still affected, use the `.deb`, or `LD_PRELOAD=/usr/lib/libwayland-client.so.0 ./AppImage` (adjust the path for your distro).
diff --git a/README.es.md b/README.es.md
index 7e21fee6..883d5b33 100644
--- a/README.es.md
+++ b/README.es.md
@@ -91,7 +91,7 @@ El primer arranque descarga el runtime de Node y el núcleo Harness (si `dsh` ya
**Paquete sin conexión (Windows / macOS / Linux):** En Releases también está `Deepseek.Harness.Desktop_Bundle_<versión>.<ext>`: trae el runtime de Node y el núcleo Harness, así que **el primer arranque no necesita red**. Pensado para equipos sin internet o con lista blanca (los plugins preestablecidos y de la comunidad sí necesitan red, y las funciones basadas en git —como los worktrees— necesitan un Git del sistema). En Linux el paquete va dentro del `.deb`, cuyos recursos en `/usr/lib` son de solo lectura: hay que corregir los permisos de ese directorio después de instalarlo como root.
-> **Nota Wayland en Linux (PikaOS / GNOME Wayland / Ubuntu 22.04+):** el AppImage puede crashear o verse negro en Wayland por WebKitGTK; la app corrige sola el caso común. <details><summary>Si igual crashea / se ve negro:</summary><br>**Preferí el `.deb`** (verificado en PikaOS 4 Wayland), o ejecutá a mano `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`. Si no aparecen los iconos, copiá los iconos `hicolor` de la app a `~/.local/share/icons` y ejecutá `update-desktop-database`.<br></details>
+> **Nota Wayland en Linux (PikaOS / GNOME Wayland / Ubuntu 22.04+):** el hook GTK del AppImage fuerza `GDK_BACKEND=x11`; cuando hay una sesión Wayland disponible la app lo descarta y usa el backend Wayland nativo (issue #789), y el arreglo automático de WebKitGTK sigue aplicándose. <details><summary>Si igual crashea / se ve negro, o necesitás la mascota siempre visible:</summary><br>**Preferí el `.deb`** (verificado en PikaOS 4 Wayland); para conservar XWayland definí `DSH_FORCE_XWAYLAND=1` (o activá `force_xwayland` en los ajustes); respaldo de render `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 ./AppImage`. Si no aparecen los iconos, copiá los iconos `hicolor` de la app a `~/.local/share/icons` y ejecutá `update-desktop-database`.<br></details>
>
> **Linux de liberación continua arranca y muere al instante (Arch / CachyOS / Fedora, …):** los AppImage antiguos empaquetaban las librerías de la pila de display de la imagen de build (Ubuntu 22.04), como `libwayland-client`. Un Mesa más nuevo del sistema es incompatible a nivel ABI con ellas, así que `WebKitWebProcess` llama a `abort()`: la app **no muestra ninguna ventana ni ningún log**. El build ya elimina esas librerías (ver `.github/workflows/build-linux.yml` y `scripts/fix-appimage-host-libs.sh`); usá una versión publicada después de ese cambio. Si igual te afecta, usá el `.deb`, o `LD_PRELOAD=/usr/lib/libwayland-client.so.0 ./AppImage` (ajustá la ruta según tu distro).
diff --git a/README.md b/README.md
index a3a90449..2f14c697 100644
--- a/README.md
+++ b/README.md
@@ -89,7 +89,7 @@ brew install dsh-tauri/desktop/deepseek-harness
**离线安装包(Windows / macOS / Linux):** Releases 里另有 `Deepseek.Harness.Desktop_Bundle_<版本>.<扩展名>`:Node 运行时与 Harness 内核随包分发,**安装后首次启动无需联网**,适合内网 / 白名单环境(预设与社区插件仍需联网;git 相关能力如工作树需系统已装 Git)。Linux 的随包资源在 `.deb` 的 `/usr/lib` 下,root 安装后需补齐该目录权限。
-> **Linux Wayland 注意(PikaOS / GNOME Wayland / Ubuntu 22.04+):** AppImage 在 Wayland 下可能因 WebKitGTK 黑屏/崩溃,应用已自动处理常见情形。 <details><summary>若仍黑屏/崩溃:</summary><br>**改用 `.deb`**(已验证 PikaOS 4 Wayland),或手动 `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`。图标不显示时,将应用内 `hicolor` 图标复制到 `~/.local/share/icons` 并运行 `update-desktop-database`。<br></details>
+> **Linux Wayland 注意(PikaOS / GNOME Wayland / Ubuntu 22.04+):** AppImage 自带的 GTK 启动钩子会强制 `GDK_BACKEND=x11`,应用检测到可用的 Wayland 会话时会丢弃它、改用原生 Wayland(issue #789);WebKitGTK 的黑屏/崩溃兜底仍自动生效。 <details><summary>若仍黑屏/崩溃,或需要桌宠置顶:</summary><br>**改用 `.deb`**(已验证 PikaOS 4 Wayland);要保留 XWayland 设 `DSH_FORCE_XWAYLAND=1`(或在设置里打开 `force_xwayland`);渲染兜底 `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 ./AppImage`。图标不显示时,将应用内 `hicolor` 图标复制到 `~/.local/share/icons` 并运行 `update-desktop-database`。<br></details>
>
> **Linux 滚动发行版启动即崩(Arch / CachyOS / Fedora 等):** 旧版 AppImage 会随包携带构建镜像(Ubuntu 22.04)的 `libwayland-client` 等显示栈库,较新的宿主 Mesa 与之 ABI 不匹配会导致 `WebKitWebProcess` 直接 `abort()`——表现为**双击后没有任何界面、也没有任何日志**。构建阶段已剔除这些库(见 `.github/workflows/build-linux.yml` 与 `scripts/fix-appimage-host-libs.sh`),请使用修复后发布的版本;仍受影响时可用 `.deb`,或 `LD_PRELOAD=/usr/lib/libwayland-client.so.0 ./AppImage`(路径按发行版调整)。
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 587c1299..7b203040 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -15,8 +15,8 @@ pub fn patch_core_dir(core_dir: &std::path::Path) -> Result<(), String> {
service::patch::apply_all_at(core_dir)
}
-/// 应用入口:先做 Wayland 环境兼容(见 `should_apply_wayland_egl_workaround`),
-/// 再初始化日志、装配桌面端并进入事件循环。
+/// 应用入口:先做 Wayland 环境兼容(见 `should_apply_wayland_egl_workaround` 与
+/// `should_restore_wayland_backend`),再初始化日志、装配桌面端并进入事件循环。
pub fn run() {
// Wayland EGL workaround:仅 AppImage 需要(见 `should_apply_wayland_egl_workaround`)。
if should_apply_wayland_egl_workaround(
@@ -37,13 +37,31 @@ pub fn run() {
}
if !applied.is_empty() {
// 此处在 logger::init() 之前执行,log 宏尚无 subscriber,用 eprintln 输出
- eprintln!("[wayland] set {} for WebKitGTK EGL", applied.join("="));
+ eprintln!("[wayland] set {} for WebKitGTK EGL", applied.join(" "));
}
}
// 强制 XWayland(默认关闭的设置项,见 `should_force_xwayland`)。必须在此处执行:
// GDK 只在初始化时读一次 GDK_BACKEND,建窗之后再改无效。
+ let force_xwayland =
+ config::force_xwayland_setting() || std::env::var_os("DSH_FORCE_XWAYLAND").is_some();
+ // AppImage 的 GTK 钩子把 GDK_BACKEND 强制成 x11(见 `should_restore_wayland_backend`):
+ // 默认丢掉,让 GTK 与 WebKit 一起走原生 Wayland;用户显式要 XWayland 时不动它。
+ if should_restore_wayland_backend(
+ std::env::var_os("APPIMAGE").is_some(),
+ &std::env::var("WAYLAND_DISPLAY").unwrap_or_default(),
+ &std::env::var("GDK_BACKEND").unwrap_or_default(),
+ ) && !force_xwayland
+ {
+ std::env::remove_var("GDK_BACKEND");
+ // 同上,logger::init() 尚未执行,只能用 eprintln。这里是「原生 Wayland 反而起不来」
+ // 时唯一的提示位:那种情况下窗口不会出现,用户在应用内看不到任何日志或设置项。
+ eprintln!(
+ "[wayland] dropped the AppImage hook's GDK_BACKEND=x11 to use native Wayland (issue #789)"
+ );
+ eprintln!("[wayland] set DSH_FORCE_XWAYLAND=1 to keep XWayland instead");
+ }
if should_force_xwayland(
- config::force_xwayland_setting(),
+ force_xwayland,
&std::env::var("WAYLAND_DISPLAY").unwrap_or_default(),
&std::env::var("GDK_BACKEND").unwrap_or_default(),
&std::env::var("DISPLAY").unwrap_or_default(),
@@ -107,6 +125,36 @@ fn should_apply_wayland_egl_workaround(session_type: &str, appimage_present: boo
session_type == "wayland" && appimage_present
}
+/// AppImage 的 GTK 启动钩子强制出来的 XWayland 后端是否应被丢弃。
+///
+/// linuxdeploy-plugin-gtk 为绕开 tauri#8541(Ubuntu 20.04 构建的 AppImage 在 Fedora 39
+/// 上以 `GLib-GIO-ERROR … xsettings` 退出)无条件 `export GDK_BACKEND=x11`,于是 Wayland
+/// 会话下的 AppImage 永远以 XWayland 客户身份运行 GTK3,并按 AppImage 自带的 immodules
+/// 缓存选中 XIM 输入法模块。上游已认定这是缺陷:tauri#15781「钩子覆盖用户显式设置的
+/// GDK_BACKEND,静默降级到 XWayland 且不报错」,#11790 记下的结论是「hardcoded,需要时
+/// 从 Rust 侧覆盖」,PR #16062 已在 dev 分支删掉该行但尚未发布,linuxdeploy-plugin-gtk
+/// 的 master 也仍在使用它(`@tauri-apps/cli` 2.11.4 在 tools 目录缺失时直接下载 master)。
+///
+/// issue #789 的现场与该降级吻合:Wayland + AppImage 下点击内嵌 iframe 后整个 WebView
+/// 不再出帧(顶层 navbar 照常可点,拖窗口边框才刷出几帧,剪贴板为空)。丢掉强制值后
+/// GTK 与 WebKit 同样工作在 Wayland 上,不再出现 X11 窗口配 Wayland 加速面的错配。
+/// 判定用 `WAYLAND_DISPLAY` 而非 `XDG_SESSION_TYPE`:后者由 pam_systemd 设置,从 TTY
+/// 直接起的合成器下为空,而 GDK 照样连上 Wayland(与 [`pet_overlay_supported`] 同一理由)。
+///
+/// 只认裸 `x11`:`wayland` / `x11,wayland` 这类优先级列表只可能来自用户或启动脚本,不覆盖。
+///
+/// `force_xwayland` 的解析早于 `migrate_app_data_dir`(见 `config::force_xwayland_setting`):
+/// 旧标识符升级来的用户首次启动读不到设置文件。但该设置 2026-09-23 才引入(38d7f01b),
+/// 标识符 2026-09-21 已改短(67f058c9),旧 store 里不可能存在 `force_xwayland`,
+/// 因此这条读取盲区不会让本判定丢掉任何已持久化的用户意图。
+fn should_restore_wayland_backend(
+ appimage_present: bool,
+ wayland_display: &str,
+ gdk_backend: &str,
+) -> bool {
+ appimage_present && !wayland_display.is_empty() && gdk_backend == "x11"
+}
+
/// 桌宠窗口的置顶与绝对定位能力是否可用。
///
/// xdg-shell 不提供这两项能力。tao 的 Linux 后端基于 GTK3,`always_on_top` 与
@@ -180,6 +228,28 @@ mod tests {
assert!(!should_apply_wayland_egl_workaround("", false));
}
+ #[test]
+ fn appimage_hook_forced_x11_backend_is_dropped_on_wayland() {
+ // AppImage 自带钩子的强制值 + Wayland 套接字可用:丢弃,改走原生 Wayland。
+ assert!(should_restore_wayland_backend(true, "wayland-0", "x11"));
+ // 用户或启动脚本显式给的优先级列表不是钩子的裸 x11,保持权威。
+ assert!(!should_restore_wayland_backend(
+ true,
+ "wayland-0",
+ "wayland"
+ ));
+ assert!(!should_restore_wayland_backend(
+ true,
+ "wayland-0",
+ "x11,wayland"
+ ));
+ // 没有 Wayland 套接字(纯 X11 会话 / macOS / Windows):GDK 自己挑后端。
+ assert!(!should_restore_wayland_backend(true, "", "x11"));
+ // 宿主安装包没有该钩子,变量来自用户,不动。
+ assert!(!should_restore_wayland_backend(false, "wayland-0", "x11"));
+ assert!(!should_restore_wayland_backend(false, "wayland-0", ""));
+ }
+
#[test]
fn pet_overlay_unsupported_only_on_native_wayland() {
// 原生 Wayland:GTK 的置顶与定位调用是 no-op,桌宠被主窗口遮挡。