A patched copy of gpui-pre-windows 0.3.9, the
Windows platform backend of gpui-pre 0.3.9 (a published
snapshot of Zed's gpui_windows at zed@93d7456). It is the backend used by
GPUI Kit 0.8.0.
What it fixes: upstream redraws every window on every display refresh, even when nothing
changed and even when the window is minimized. On a 180 Hz monitor an idle, empty GPUI window
used 2–4 % of a CPU core. With this patch a window is only redrawn when GPUI asks for a frame
(something became dirty, an animation or on_next_frame is pending), so idle windows cost
nothing.
| Window (180 Hz, release) | Upstream 0.3.9 | Patched |
|---|---|---|
| Bare GPUI window, visible | 3.76 % of a core, ~550 main-thread wakeups/s | 0.01 % |
| Bare GPUI window, minimized | 3.36 % | 0.00 % |
| Terminal app, idle with a blinking cursor | 2.78 % | 0.25 % |
The first frame after an idle period is drawn immediately (no wait for the next vblank), so
input latency does not get worse; continuous animation is still paced by DwmFlush.
In your workspace root Cargo.toml (your dependency graph must resolve gpui-pre = "=0.3.9",
e.g. through gpui-kit = "=0.8.0"):
[patch.crates-io]
gpui-pre-windows = { git = "https://github.com/RusticStack/gpui-pre-windows", tag = "v0.3.9-skua.1" }Check it is active with cargo tree -i gpui-pre-windows (the source shows the git URL).
The history is two commits: the unmodified crate as published on crates.io, then the patch
(5 files, ~140 lines, every changed line marked SKUA PATCH (G1-F10)). Details, design and
measurements: SKUA-PATCH.md.
In short: GPUI core already calls PlatformWindow::frame_waker whenever a window needs a frame;
the Windows backend did not implement it. The patch implements it (a shared condvar the vsync
thread parks on), invalidates only the windows that asked, and requests frames explicitly where
the old code relied on the constant redraw (deferred draws, restore from minimized, touchpad
Direct Manipulation gestures and inertia).
Tested on Windows 11 with the Skua app: typing, resize, scrolling, selection, maximize/restore, a 530 ms cursor blink and pixel-identical golden screenshots. Not tested on a touchpad.
Apache-2.0, like upstream (LICENSE-APACHE). Copyright of the original code: Zed Industries.
The modifications are marked in the source and described in SKUA-PATCH.md.