Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

fix: scope the Linux WebKit workaround to Wayland

Tw935457cd0ef1d6
diff --git a/docs/faq.md b/docs/faq.md
index 342095d0..22902098 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 normally enables WebKitGTK workarounds that help blank-window cases on Linux, but those same flags can make input and window controls unreliable on some Wayland compositors. The `PAKE_LINUX_WEBKIT_SAFE_MODE` variable lets you choose the safer rendering mode for your compositor.
+On Wayland, Pake enables WebKitGTK workarounds that help blank-window cases without a GPU, but those same flags can make input and window controls unreliable on some compositors. X11 sessions never needed the workarounds and are left on the native WebKit path, where the flags would instead crash playback. The `PAKE_LINUX_WEBKIT_SAFE_MODE` variable overrides either default.
---
diff --git a/docs/faq_CN.md b/docs/faq_CN.md
index 95088abe..099e8522 100644
--- a/docs/faq_CN.md
+++ b/docs/faq_CN.md
@@ -305,7 +305,7 @@ PAKE_LINUX_WEBKIT_SAFE_MODE=1 ./MyApp.AppImage
```
**原因:**
-Pake 默认启用的 WebKitGTK workaround 可以缓解 Linux 白屏,但在部分 Wayland 合成器上,这些参数可能导致输入和窗口控件不可用。`PAKE_LINUX_WEBKIT_SAFE_MODE` 可以按当前合成器选择更合适的渲染模式。
+Pake 在 Wayland 下启用的 WebKitGTK workaround 可以缓解无 GPU 时的白屏,但在部分合成器上会导致输入和窗口控件不可用。X11 会话本来就不需要这组参数,默认走原生 WebKit 路径,强行启用反而会让视频播放崩溃。`PAKE_LINUX_WEBKIT_SAFE_MODE` 可以覆盖这两个默认值。
---
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 105bea18..cab4f63a 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -111,12 +111,23 @@ fn contains_niri(value: &str) -> bool {
fn should_enable_linux_webkit_safe_mode_from_values(
safe_mode: Option<&str>,
niri_socket: Option<&str>,
+ wayland_display: 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);
}
+ // The flags exist for blank screens on Wayland without a GPU (cb911ec7),
+ // and that is the only failure they were ever measured against. X11 never
+ // had it, while disabling compositing there segfaults WebKitGTK 2.52 as
+ // soon as a video plays (#1374, Intel i915 under i3). Keep them scoped to
+ // the sessions they were written for; PAKE_LINUX_WEBKIT_SAFE_MODE=1 still
+ // forces them anywhere.
+ if !is_non_empty_env_value(wayland_display) {
+ return false;
+ }
+
let is_niri_session = is_non_empty_env_value(niri_socket)
|| desktop_values
.iter()
@@ -176,6 +187,7 @@ fn apply_linux_webkit_runtime_flags() {
if !should_enable_linux_webkit_safe_mode_from_values(
safe_mode.as_deref(),
std::env::var("NIRI_SOCKET").ok().as_deref(),
+ std::env::var("WAYLAND_DISPLAY").ok().as_deref(),
&desktop_refs,
) {
return;
@@ -471,19 +483,43 @@ mod tests {
}
#[test]
- fn linux_webkit_safe_mode_stays_on_by_default() {
+ fn linux_webkit_safe_mode_stays_on_by_default_on_wayland() {
assert!(should_enable_linux_webkit_safe_mode_from_values(
None,
None,
+ Some("wayland-0"),
&[None, None, None]
));
}
+ #[test]
+ fn linux_webkit_safe_mode_stays_off_on_x11() {
+ // No WAYLAND_DISPLAY is an X11 session, where the flags never fixed
+ // anything and segfault WebKitGTK during playback (#1374).
+ assert!(!should_enable_linux_webkit_safe_mode_from_values(
+ None,
+ None,
+ None,
+ &[Some("i3"), None, None]
+ ));
+ }
+
+ #[test]
+ fn linux_webkit_safe_mode_can_be_forced_on_for_x11() {
+ assert!(should_enable_linux_webkit_safe_mode_from_values(
+ Some("1"),
+ None,
+ None,
+ &[Some("i3"), None, None]
+ ));
+ }
+
#[test]
fn linux_webkit_safe_mode_is_disabled_for_niri_socket() {
assert!(!should_enable_linux_webkit_safe_mode_from_values(
None,
Some("/run/user/501/niri.sock"),
+ Some("wayland-0"),
&[None, None, None]
));
}
@@ -493,6 +529,7 @@ mod tests {
assert!(!should_enable_linux_webkit_safe_mode_from_values(
None,
None,
+ Some("wayland-0"),
&[Some("niri"), None, None]
));
}
@@ -502,6 +539,7 @@ mod tests {
assert!(should_enable_linux_webkit_safe_mode_from_values(
Some("1"),
Some("/run/user/501/niri.sock"),
+ Some("wayland-0"),
&[Some("niri"), None, None]
));
}
@@ -513,6 +551,7 @@ mod tests {
!should_enable_linux_webkit_safe_mode_from_values(
Some(value),
None,
+ Some("wayland-0"),
&[None, None, None]
),
"expected {value} to disable safe mode"