From 7c37424fcf3922f4daed4bb2af625065bf506e9e Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 13 Nov 2026 00:46:07 +0800 Subject: [PATCH] gui: the Linux app draws without backdrop blur, which WebKitGTK repaints on the CPU each frame (Lsheng2012 on X) Lsheng2012 (CachyOS, KDE, i7-12700H, RTX 3070 Ti Laptop) found the UI laggy. webkit_linux.go turns accelerated compositing off under Wayland and without a GPU, and there every backdrop-filter is software-painted for its whole box each frame. body.linux now drops it on .modal, .pop, the panel's profile chips, Settings' sticky head and the confirm ::backdrop. Layout unchanged. Measured (WebKitGTK 2.52.6, Xvfb on magpie-desktop, 240 rAF scroll frames of 600 rows, 1100x760): no blur 16.2ms, sticky head blur 16.2ms, full-window modal blur(8px) 25.0ms with compositing off (16.4ms with it on). Run: linux-no-backdrop-blur.test.cjs in chromium and webkit on mote (green; red with the rule removed by hand), go test ./internal/gui asset tests. Not tried: NVIDIA, Wayland/KDE, the omarchy VM, a full suite. The sticky head cost nothing in the probe, so the modal is the measured gain; if the reporter is still laggy the cause is elsewhere (CPU painting at HiDPI), and we ask for their session type, driver and version. --- docs/subsystems/gui-shell.md | 1 + internal/gui/assets/app.css | 8 +++++ .../gui/tests/linux-no-backdrop-blur.test.cjs | 35 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 internal/gui/tests/linux-no-backdrop-blur.test.cjs diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index 5f5f0bbb8..59e3717a5 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -692,6 +692,7 @@ covers it in both engines, every language and a narrow window. - On Linux the panel is a solid window, as the main window is, and its page paints `--bg` whole (`panelOptions`, `body.linux.panel` in `app.css`). The Mac's and Windows' panels stay translucent. A see-through panel is an RGBA, app-paintable GTK window under a transparent webview, and on KDE Plasma 6 its page, painted at 93%, left a fainter copy of the old scroll position as it scrolled (Wayland and XWayland, compositing mode on or off) while the main window never did (#1803, `TestPanelSolidOnLinux`, `panel-linux-opaque.test.cjs`). Xvfb with picom on WebKitGTK 2.54 doesn't show the ghost either way, so the fix rests on the reporter's machine. - A Wayland window can't place itself, so under Hyprland and niri the compositor is asked to put the panel under the bar. Under Hyprland `placePanel` gives it a window rule at the cursor (`omarchy.PlacePanel`) and closes it on a click outside (`omarchy.ReportClicks`). The rule names the monitor under the cursor and moves the panel to x, y from that monitor's corner (`omarchy.PanelAt`): Hyprland adds the window's monitor's place to a `move`, so a position across the whole layout put the panel off a monitor not at 0,0 (#1785, `TestPanelAtMonitorOffScreenOrigin`). The cursor and the clients' places that `omarchy.ClickedOutside` compares are both across the layout. niri (`omarchy.Niri`, `NIRI_SOCKET` set) takes no rules at runtime and doesn't report the cursor. There `omarchy.NiriPanel` watches niri's event stream and moves the panel each time it opens: the window of magpie's pid titled `panelTitle`, moved with `MoveFloatingWindow` (after `MoveWindowToFloating` if it was tiled). It goes 6 px under the working area's top, centred on the x the tray host passed to `Activate(x, y)`. Wails keeps that x in its Linux tray (`trayClick`, `TestTrayClickIsWails`), and it is taken across the bar, since that's all a Wayland bar knows. With no click (`magpie panel`), or with one off the output, it goes top right. Wails' `HideOnFocusLost` closes it, since a click on another window takes niri's focus. It still opens in the middle and slides up, and a bar at the bottom or the side isn't accounted for (#1670). - Wails calls the tray's click handler both for the icon's click (`Activate`) and when the tray host opens the icon's menu (dbusmenu's "opened" event). KDE opens the menu on a right-click, and the panel that click opened took the focus and shut the menu on Wayland. On Linux the handler ignores the call when it comes from the menu opening (`menuOpening` in [`trayclick.go`](../../internal/gui/trayclick.go), which looks for Wails' `(*linuxSystemTray).Event` among its callers; `TestTrayMenuOpenFrameIsWails` fails if Wails renames it or stops calling the handler there) (#1430). +- On Linux the app draws without backdrop blur (`body.linux` rules at the end of `app.css`; `linux-no-backdrop-blur.test.cjs`): `webkit_linux.go` turns accelerated compositing off under Wayland and without a GPU, and there a blur is repainted by the CPU on every frame (a full-window modal took 25ms a frame against 16ms with none, in WebKitGTK 2.52 on Xvfb). The modal, pickers and Settings' sticky head are 92% or more opaque, so the blur is barely seen. Not reproduced on NVIDIA under Wayland (no such machine), so a report of lag there may have another part (#3150). - On GTK 3 builds, the app gives GDK a font DPI before the first webview when it has none (`fontDPI`, [`fontdpi_gtk3.h`](../../internal/gui/fontdpi_gtk3.h)). GDK's unset value is -1, and WebKitGTK 2.54's GTK 3 settings reader multiplies it by 1024 unchecked, so every page lays out at a negative width with a 9000000px font (#1371). An unset DPI takes `gtk-xft-dpi`, or 96, times a valid `GDK_DPI_SCALE`; a positive one is left alone. Wails initialises GTK (its GtkApplication) only inside `Run` and makes each window from a default-idle-priority callback on the main loop, so `fontDPI`, called just before `Run`, queues the check as a `G_PRIORITY_HIGH` idle: it runs on the main thread after GTK's own start, before the first window. `TestFontDPIUnset` opens a real WebKitGTK page through `magpie_font_dpi` and needs a display (Xvfb). - Tests never touch a live agent config. The package's `TestMain` runs under `testenv`'s home of its own. A macOS test that shows windows runs them in a process of its own through `runAppKit` ([`appkit_darwin_test.go`](../../internal/gui/appkit_darwin_test.go)). AppKit and WebKit take their home from the account, not from HOME, so `runAppKit` gives them a temporary one with `CFFIXED_USER_HOME`; appearance, contrast and languages still come from the account. The test fails when that process leaves a folder in the real `~/Library/WebKit` or `~/Library/Caches`. Playwright tests serve `assets/` with isolated `/api` fixtures. - `POST /api/settings/codex-auto-review` accepts an empty value (Codex's own choice, or the session's model when Codex's sign-in is on a Free plan), `session` (the session's own model when it is one of magpie's; "Same as the session" in the picker), or an exact model/group ID in `provider.Served`, including unlisted providers. A known provider with an unknown or empty model name is rejected without changing the saved reviewer or catalog tag. Generic gateway request resolution remains permissive; it is not the validator for this setting. See `Handler` in [`api.go`](../../internal/gui/api.go) and `TestCodexAutoReviewSetting` in [`codex_auto_review_test.go`](../../internal/gui/codex_auto_review_test.go). diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 1429e0bbe..9afde8188 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -5289,3 +5289,11 @@ body .row.agent .ag-prefs .row.pref .who { display: block; } .server-pin .hint.err { color: var(--red); overflow-wrap: anywhere; } .server-pin .pin-acts { display: flex; flex-wrap: wrap; gap: 12px; } .server-pin .pin-peek.busy { pointer-events: none; opacity: .6; } +/* WebKitGTK draws without accelerated compositing (webkit_linux.go), so a + backdrop blur is redone by the CPU for its whole box on every frame: a + full-window modal took 25ms a frame where the same page took 16ms with none + (lagging scroll, Lsheng2012 on X, KDE). Each of these grounds is 92% opaque + or a dim, so the blur is barely seen; the Linux app draws without it. */ +body.linux .modal, body.linux .pop, body.linux.panel .profiles.open, +body.linux:not(.side-nav) #view-settings .set-head::before, +body.linux .action-confirm::backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; } diff --git a/internal/gui/tests/linux-no-backdrop-blur.test.cjs b/internal/gui/tests/linux-no-backdrop-blur.test.cjs new file mode 100644 index 000000000..2081513e6 --- /dev/null +++ b/internal/gui/tests/linux-no-backdrop-blur.test.cjs @@ -0,0 +1,35 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// The Linux app's WebKitGTK draws without accelerated compositing, where a +// backdrop blur is repainted by the CPU on every frame (a full-window modal +// cost 25ms a frame against 16ms with none). On Linux the app's modals, +// pickers and sticky Settings head draw without the blur; elsewhere they keep it. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const css = path.resolve(__dirname, "../assets/app.css"); +const probe = `
+
x
`; + +for (const [name, engine] of [["chromium", chromium], ["webkit", webkit]]) { + test(`${name}: backdrop blur is off on Linux only`, async () => { + const b = await engine.launch(); + try { + const out = {}; + for (const cls of ["linux", ""]) { + const page = await b.newPage(); + await page.setContent(`${probe}`); + await page.addStyleTag({ content: await fs.readFile(css, "utf8") }); + out[cls || "other"] = await page.evaluate(() => { + const bf = (el, pseudo) => { const s = getComputedStyle(el, pseudo); return s.backdropFilter || s.webkitBackdropFilter || "none"; }; + return [bf(m), bf(p), bf(h, "::before")]; + }); + await page.close(); + } + assert.deepEqual(out.linux, ["none", "none", "none"]); + for (const v of out.other) assert.notEqual(v, "none"); + } finally { await b.close(); } + }); +}