Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
fix: restore the niri exception the flag split dropped
Tw93c8fe8a3f1a11
diff --git a/docs/faq.md b/docs/faq.mdindex 484ba8eb..f16432e6 100644--- a/docs/faq.md+++ b/docs/faq.md@@ -308,7 +308,7 @@ PAKE_LINUX_WEBKIT_SAFE_MODE=1 ./MyApp.AppImage```**Why This Happens:**-Pake sets two WebKitGTK variables on Linux, and they have different defaults. `WEBKIT_DISABLE_DMABUF_RENDERER` is on everywhere, because the blank window it prevents also happens on X11 with the NVIDIA proprietary driver. `WEBKIT_DISABLE_COMPOSITING_MODE` is on for Wayland only, where it fixes a blank screen without a GPU; on X11 it never fixed anything and it crashes video playback instead. `PAKE_LINUX_WEBKIT_SAFE_MODE` overrides both at once: `1` forces both on, `0` turns both off.+Pake sets two WebKitGTK variables on Linux. `WEBKIT_DISABLE_DMABUF_RENDERER` is on everywhere except niri, because the blank window it prevents also happens on X11 with the NVIDIA proprietary driver. `WEBKIT_DISABLE_COMPOSITING_MODE` is on for Wayland only, where it fixes a blank screen without a GPU. On WebKitGTK 2.52 both variables reach the same switch, so either one on its own turns hardware acceleration off, which is why `PAKE_LINUX_WEBKIT_SAFE_MODE` is the setting that matters: `1` forces both on, `0` turns both off.---diff --git a/docs/faq_CN.md b/docs/faq_CN.mdindex c393f012..ac9bd6f7 100644--- a/docs/faq_CN.md+++ b/docs/faq_CN.md@@ -305,7 +305,7 @@ PAKE_LINUX_WEBKIT_SAFE_MODE=1 ./MyApp.AppImage```**原因:**-Pake 在 Linux 上会设两个 WebKitGTK 变量,默认值不一样。`WEBKIT_DISABLE_DMABUF_RENDERER` 在所有会话下都开,因为它挡住的白屏在 X11 配 NVIDIA 闭源驱动时同样会出现。`WEBKIT_DISABLE_COMPOSITING_MODE` 只在 Wayland 下开,它解决的是无 GPU 时的白屏,而在 X11 上它没修好过任何东西,反而会让视频播放崩溃。`PAKE_LINUX_WEBKIT_SAFE_MODE` 一次覆盖两个:`1` 全开,`0` 全关。+Pake 在 Linux 上会设两个 WebKitGTK 变量。`WEBKIT_DISABLE_DMABUF_RENDERER` 除 niri 外都开,因为它挡住的白屏在 X11 配 NVIDIA 闭源驱动时同样会出现。`WEBKIT_DISABLE_COMPOSITING_MODE` 只在 Wayland 下开,它解决的是无 GPU 时的白屏。在 WebKitGTK 2.52 上这两个变量落到同一个开关,任意一个单独打开都会关掉硬件加速,所以真正起作用的是 `PAKE_LINUX_WEBKIT_SAFE_MODE`:`1` 全开,`0` 全关。---diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 146ef348..77394efe 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -107,25 +107,51 @@ fn contains_niri(value: &str) -> bool {.any(|part| part.eq_ignore_ascii_case("niri"))}+#[cfg(any(target_os = "linux", test))]+fn is_niri_session(niri_socket: Option<&str>, desktop_values: &[Option<&str>]) -> bool {+ is_non_empty_env_value(niri_socket)+ || desktop_values+ .iter()+ .flatten()+ .any(|value| contains_niri(value))+}+/// The two WebKit workarounds have different origins and therefore different/// scopes, which one gate cannot express.////// `WEBKIT_DISABLE_DMABUF_RENDERER` came from #1117 (96e57376) for Linux/// stability in general, three months before anything Wayland-specific, and/// upstream still reports the blank window it prevents on X11 with the NVIDIA-/// proprietary driver (tauri-apps/tauri#9394). It stays on for every session.+/// proprietary driver (tauri-apps/tauri#9394), so it stays on everywhere except+/// niri.+///+/// niri is excepted because #1226 was fixed by dropping both variables, and on+/// WebKitGTK 2.52 either one alone is enough to undo that: disabling the dmabuf+/// renderer leaves `AcceleratedBackingStore::rendererBufferTransportMode` empty,+/// `checkRequirements()` then returns false, and `HardwareAccelerationManager`+/// clears `m_canUseHardwareAcceleration` through an OR. Setting only this one+/// would put niri back in the state #1226 reported.#[cfg(any(target_os = "linux", test))]-fn should_disable_dmabuf_renderer(safe_mode: Option<&str>) -> bool {- match safe_mode.filter(|value| !value.trim().is_empty()) {- Some(value) => !is_disabled_env_value(value),- None => true,+fn should_disable_dmabuf_renderer(+ safe_mode: Option<&str>,+ niri_socket: Option<&str>,+ desktop_values: &[Option<&str>],+) -> bool {+ if let Some(value) = safe_mode.filter(|value| !value.trim().is_empty()) {+ return !is_disabled_env_value(value);}++ !is_niri_session(niri_socket, desktop_values)}/// `WEBKIT_DISABLE_COMPOSITING_MODE` came from cb911ec7, for a blank screen on-/// Wayland without a GPU. X11 never had that failure, and disabling compositing-/// there segfaults WebKitGTK 2.52 as soon as a video decodes (#1374, Intel i915-/// under i3), so this one is Wayland-only. niri keeps its existing exception.+/// Wayland without a GPU. X11 never had that failure, so this one is+/// Wayland-only, with the same niri exception.+///+/// It is not on its own what segfaults playback in #1374. Both variables reach+/// the same boolean on WebKitGTK 2.52, so the state that crashes is hardware+/// acceleration being off, whichever variable turned it off. Narrowing this one+/// changed nothing on X11 while the dmabuf flag still applied there./// `PAKE_LINUX_WEBKIT_SAFE_MODE` still forces or suppresses both anywhere.#[cfg(any(target_os = "linux", test))]fn should_disable_compositing_mode(@@ -152,13 +178,7 @@ fn should_disable_compositing_mode(return false;}- let is_niri_session = is_non_empty_env_value(niri_socket)- || desktop_values- .iter()- .flatten()- .any(|value| contains_niri(value));-- !is_niri_session+ !is_niri_session(niri_socket, desktop_values)}#[cfg(any(target_os = "linux", test))]@@ -208,7 +228,9 @@ fn apply_linux_webkit_runtime_flags() {.map(|value| value.as_deref()).collect::<Vec<_>>();- if should_disable_dmabuf_renderer(safe_mode.as_deref())+ let niri_socket = std::env::var("NIRI_SOCKET").ok();++ if should_disable_dmabuf_renderer(safe_mode.as_deref(), niri_socket.as_deref(), &desktop_refs)&& std::env::var(WEBKIT_DISABLE_DMABUF_RENDERER).is_err(){std::env::set_var(WEBKIT_DISABLE_DMABUF_RENDERER, "1");@@ -216,7 +238,7 @@ fn apply_linux_webkit_runtime_flags() {if should_disable_compositing_mode(safe_mode.as_deref(),- std::env::var("NIRI_SOCKET").ok().as_deref(),+ niri_socket.as_deref(),std::env::var("WAYLAND_DISPLAY").ok().as_deref(),std::env::var(GDK_BACKEND).ok().as_deref(),&desktop_refs,@@ -508,30 +530,63 @@ mod tests {}#[test]- fn dmabuf_renderer_stays_disabled_on_every_session() {+ fn dmabuf_renderer_stays_disabled_outside_niri() {// #1117 was never Wayland-scoped, and upstream still reports the blank// window it prevents on X11 with the NVIDIA proprietary driver.- assert!(should_disable_dmabuf_renderer(None));- assert!(should_disable_dmabuf_renderer(Some("1")));+ let none = [None, None, None];+ assert!(should_disable_dmabuf_renderer(None, None, &none));+ assert!(should_disable_dmabuf_renderer(Some("1"), None, &none));}#[test]fn dmabuf_renderer_can_be_re_enabled_explicitly() {+ let none = [None, None, None];for value in ["0", "false", "off", "no", "native", "disabled"] {assert!(- !should_disable_dmabuf_renderer(Some(value)),+ !should_disable_dmabuf_renderer(Some(value), None, &none),"expected {value} to restore the dmabuf renderer");}}#[test]- fn x11_keeps_dmabuf_disabled_but_keeps_compositing() {- // The exact shape of #1374: an X11 session gets the stability flag it- // has had since #1117, and does not get the compositing flag that- // segfaults playback there.+ fn dmabuf_renderer_is_kept_for_niri_socket() {+ // #1226 was fixed by dropping both variables. Either one alone puts a+ // niri session back into the state it reported, because both reach the+ // same hardware-acceleration boolean in WebKitGTK 2.52.+ assert!(!should_disable_dmabuf_renderer(+ None,+ Some("/run/user/501/niri.sock"),+ &[None, None, None]+ ));+ }++ #[test]+ fn dmabuf_renderer_is_kept_for_niri_desktop() {+ assert!(!should_disable_dmabuf_renderer(+ None,+ None,+ &[Some("niri"), None, None]+ ));+ }++ #[test]+ fn dmabuf_renderer_can_be_forced_on_for_niri() {+ assert!(should_disable_dmabuf_renderer(+ Some("1"),+ Some("/run/user/501/niri.sock"),+ &[Some("niri"), None, None]+ ));+ }++ #[test]+ fn x11_keeps_dmabuf_disabled_and_skips_compositing() {+ // The shape of #1374: an X11 session still gets the stability flag it+ // has had since #1117, and does not get the compositing one. Both clear+ // the same hardware-acceleration boolean, so leaving compositing unset+ // here does not by itself restore acceleration.let desktop = [Some("i3"), None, None];- assert!(should_disable_dmabuf_renderer(None));+ assert!(should_disable_dmabuf_renderer(None, None, &desktop));assert!(!should_disable_compositing_mode(None, None, None, None, &desktop));