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: use SHM rendering on Wayland with WebKitGTK 2.52+

Tw933c978e1e765e
diff --git a/AGENTS.md b/AGENTS.md
index 1ef76267..7c030230 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -115,7 +115,7 @@ Proactive latent-bug sweeps use `.agents/skills/bugs/SKILL.md`. Pick one row and
- Find's DOM-mark fallback must not observe its own highlighter mutations. Pause observation while rescanning/updating marks, then resume only while Find is open; real page edits must still refresh results. A mock without MutationObserver cannot prove this path. Icon download deadlines likewise cover response bodies, not just response headers.
- Safe clipboard shortcuts (Ctrl+C/X/V/A) on Linux/Windows are bridged in `src-tauri/src/inject/event.js`. Copy/cut/select-all stay in the trusted `handleClipboardShortcut` keydown path; Ctrl+V must leave keydown unhandled so the native WebView paste event preserves images, files, and rich formats, with text-only `navigator.clipboard.readText()` fallback allowed only from a trusted keyup when no native paste event fired. The bridge is gated on `isNonMacDesktop()` and `event.isTrusted`, only acts on editable/selected targets, and must never fire on macOS (native shortcuts already work). Locked by `event-clipboard-shortcuts.test.js` tests `lets native paste preserve non-text clipboard data` and `falls back to clipboard text only when native paste does not fire`.
- Notification flows cross injected JS, Tauri invokes, capabilities, and native notification plugins. Verify the Rust capability and JS caller together.
-- WebKit compositing behavior is platform-sensitive on Linux/Wayland. Runtime flag decisions live in `src-tauri/src/lib.rs`; keep the default conservative, cover compositor exceptions with unit tests, and document user-facing fallbacks in `docs/faq*.md`. WebKitGTK 2.52+ X11 uses SHM instead of disabling the renderer; use the loaded library version, preserve explicit variables, and keep older WebKit/Wayland on their existing path. Keep the niri exception in both legacy gates and test the combined mode, including safe-mode overrides.
+- WebKit compositing behavior is platform-sensitive on Linux/Wayland. Runtime flag decisions live in `src-tauri/src/lib.rs`; keep the default conservative, cover compositor exceptions with unit tests, and document user-facing fallbacks in `docs/faq*.md`. WebKitGTK 2.52+ uses SHM instead of disabling the renderer on both X11 and Wayland (#1374, #1386): either legacy flag turns hardware acceleration off and crashes video. Use the loaded library version, preserve explicit variables, and keep older WebKit on its existing path. Keep the niri exception in both legacy gates and test the combined mode, including safe-mode overrides.
- Linux AppImage reports often include harmless GTK, appindicator, or GStreamer warnings. Separate optional runtime warnings from the actual symptom before changing code; input/click failures on pure Wayland compositors are not the same class as blank-window failures.
- Stable `V*` Docker publication updates both the version tag and `latest`; verify matching registry manifest digests and the image's source revision. Quality validates the actual image CLI and both DEB/AppImage artifacts before a release tag is pushed. AppImage bundling requires `xdg-open` from `xdg-utils` in the image: a successful image build or DEB alone does not cover that dependency. Require both requested artifacts because the CLI intentionally allows partial success across formats.
- Release state can be split. npm Trusted Publishing can succeed before the popular-app release workflow finishes, and GitHub Release assets can exist while a workflow run still shows queued or in progress. Report each surface explicitly.
diff --git a/docs/faq.md b/docs/faq.md
index 13061ada..c7ff1361 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -308,7 +308,7 @@ PAKE_LINUX_WEBKIT_SAFE_MODE=1 ./MyApp.AppImage
```
**Why This Happens:**
-On X11 with WebKitGTK 2.52 or later, Pake uses shared-memory rendering (`WEBKIT_DMABUF_RENDERER_FORCE_SHM=1`) instead of disabling the renderer, preserving the backing store needed for video. Older WebKitGTK versions and Wayland keep the existing compatibility flags; niri keeps native rendering. Explicit WebKit variables are respected. `PAKE_LINUX_WEBKIT_SAFE_MODE=1` selects the old conservative mode, while `0` removes the two disabling flags and skips automatic workarounds.
+With WebKitGTK 2.52 or later, on both X11 and Wayland, Pake uses shared-memory rendering (`WEBKIT_DMABUF_RENDERER_FORCE_SHM=1`) instead of disabling the renderer, preserving the hardware acceleration needed for video. Older WebKitGTK versions keep the existing compatibility flags; niri keeps native rendering. Explicit WebKit variables are respected. `PAKE_LINUX_WEBKIT_SAFE_MODE=1` selects the old conservative mode, while `0` removes the two disabling flags and skips automatic workarounds.
---
diff --git a/docs/faq_CN.md b/docs/faq_CN.md
index f14b5751..196a09e1 100644
--- a/docs/faq_CN.md
+++ b/docs/faq_CN.md
@@ -305,7 +305,7 @@ PAKE_LINUX_WEBKIT_SAFE_MODE=1 ./MyApp.AppImage
```
**原因:**
-在 X11 和 WebKitGTK 2.52 及以上版本上,Pake 默认使用共享内存渲染(`WEBKIT_DMABUF_RENDERER_FORCE_SHM=1`),保留视频需要的渲染缓冲;旧版 WebKitGTK 和 Wayland 沿用现有兼容参数,niri 保持原生渲染,手动设置的 WebKit 参数也会保留。`PAKE_LINUX_WEBKIT_SAFE_MODE=1` 切回原来的保守模式,`0` 则移除两个禁用参数,不再自动添加兼容参数。
+在 WebKitGTK 2.52 及以上版本上,X11 和 Wayland 都默认使用共享内存渲染(`WEBKIT_DMABUF_RENDERER_FORCE_SHM=1`),保留视频需要的硬件加速;旧版 WebKitGTK 沿用现有兼容参数,niri 保持原生渲染,手动设置的 WebKit 参数也会保留。`PAKE_LINUX_WEBKIT_SAFE_MODE=1` 切回原来的保守模式,`0` 则移除两个禁用参数,不再自动添加兼容参数。
---
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 0148e714..e1d0b336 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -182,19 +182,17 @@ fn should_disable_compositing_mode(
!is_niri_session(niri_socket, desktop_values)
}
-// Limit the replacement to the reported WebKitGTK generation and X11 path.
-// Older WebKit and Wayland keep their existing workarounds; niri stays native.
+// On WebKitGTK 2.52+, SHM replaces both legacy flags on X11 and Wayland:
+// either flag turns hardware acceleration off, which crashes video playback
+// (#1374 on X11, #1386 on GNOME Wayland) and makes Wayland sluggish (#1192).
+// Older WebKit keeps its existing workarounds; niri stays native.
#[cfg(any(target_os = "linux", test))]
fn should_use_shm_renderer(
webkit_version: (u32, u32),
safe_mode: Option<&str>,
disable_dmabuf: bool,
- disable_compositing: bool,
) -> bool {
- webkit_version >= (2, 52)
- && !is_non_empty_env_value(safe_mode)
- && disable_dmabuf
- && !disable_compositing
+ webkit_version >= (2, 52) && !is_non_empty_env_value(safe_mode) && disable_dmabuf
}
#[cfg(any(target_os = "linux", test))]
@@ -263,16 +261,12 @@ fn apply_linux_webkit_runtime_flags() {
webkit2gtk::ffi::webkit_get_minor_version(),
)
};
- if should_use_shm_renderer(
- webkit_version,
- safe_mode.as_deref(),
- disable_dmabuf,
- disable_compositing,
- ) && std::env::var_os(WEBKIT_DISABLE_DMABUF_RENDERER).is_none()
+ if should_use_shm_renderer(webkit_version, safe_mode.as_deref(), disable_dmabuf)
+ && std::env::var_os(WEBKIT_DISABLE_DMABUF_RENDERER).is_none()
&& std::env::var_os(WEBKIT_DISABLE_COMPOSITING_MODE).is_none()
{
// Unlike disabling the renderer, SHM keeps the backing store available
- // for video while avoiding hardware-buffer imports (#1374).
+ // for video while avoiding hardware-buffer imports (#1374, #1386).
if std::env::var_os(WEBKIT_DMABUF_RENDERER_FORCE_SHM).is_none() {
std::env::set_var(WEBKIT_DMABUF_RENDERER_FORCE_SHM, "1");
}
@@ -655,37 +649,45 @@ mod tests {
#[test]
fn modern_x11_uses_shm_without_disabling_the_backing_store() {
let desktop = [Some("i3"), None, None];
- for (wayland, backend) in [(None, None), (Some("wayland-0"), Some("x11"))] {
- assert!(should_use_shm_renderer(
- (2, 52),
- None,
- should_disable_dmabuf_renderer(None, None, &desktop),
- should_disable_compositing_mode(None, None, wayland, backend, &desktop),
- ));
- }
- assert!(should_use_shm_renderer((2, 52), Some(" "), true, false));
+ assert!(should_use_shm_renderer(
+ (2, 52),
+ None,
+ should_disable_dmabuf_renderer(None, None, &desktop),
+ ));
+ assert!(should_use_shm_renderer((2, 52), Some(" "), true));
}
#[test]
- fn shm_preserves_legacy_wayland_niri_and_explicit_modes() {
- assert!(!should_use_shm_renderer((2, 50), None, true, false));
- assert!(!should_use_shm_renderer((2, 38), None, true, false));
- let desktop = [None, None, None];
- assert!(!should_use_shm_renderer(
+ fn modern_wayland_uses_shm_instead_of_disabling_compositing() {
+ // The shape of #1386: GNOME Wayland on WebKitGTK 2.52 got both legacy
+ // flags, which turn hardware acceleration off and crash video.
+ let desktop = [Some("GNOME"), None, None];
+ assert!(should_disable_compositing_mode(
+ None,
+ None,
+ Some("wayland-0"),
+ None,
+ &desktop
+ ));
+ assert!(should_use_shm_renderer(
(2, 52),
None,
should_disable_dmabuf_renderer(None, None, &desktop),
- should_disable_compositing_mode(None, None, Some("wayland-0"), None, &desktop),
));
+ }
+
+ #[test]
+ fn shm_preserves_legacy_webkit_niri_and_explicit_modes() {
+ assert!(!should_use_shm_renderer((2, 50), None, true));
+ assert!(!should_use_shm_renderer((2, 38), None, true));
let niri = [Some("niri"), None, None];
assert!(!should_use_shm_renderer(
(2, 52),
None,
should_disable_dmabuf_renderer(None, None, &niri),
- should_disable_compositing_mode(None, None, Some("wayland-0"), None, &niri),
));
for mode in ["0", "false", "1", "true"] {
- assert!(!should_use_shm_renderer((2, 52), Some(mode), true, false));
+ assert!(!should_use_shm_renderer((2, 52), Some(mode), true));
}
}