fix(cua-driver/linux): bound X11 overlay render work - #2331
Merged
Conversation
(cherry picked from commit c913f7a)
(cherry picked from commit b82e215)
(cherry picked from commit ddb0c8f)
(cherry picked from commit 4e300df)
(cherry picked from commit 07cec1d)
(cherry picked from commit 12fc510)
Render cursor-local tiles instead of allocating, scanning, and uploading the full multi-monitor root on every active frame. Reuse the X11 GC and stop the overlay thread if the connection fails. Co-authored-by: 273-B_L0 <147951788+KeroZelvin@users.noreply.github.com>
f-trycua
marked this pull request as ready for review
July 18, 2026 17:23
This was referenced Jul 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2204.
Follow-up to and salvaged from #2258.
Why #2258 was not sufficient
#2258 correctly removes the initial idle loop, but its own validation boundary records a later live desktop lock. The remaining active path still rebuilds and uploads the entire root window at roughly 60 Hz for the full duration of a glide. On a 7680×2160 multi-monitor root, that is 63.3 MiB per frame (about 3.7 GiB/s of raw pixel work before allocation, XShape, and protocol overhead).
A guarded Azure/Xvfb repro at 7680×2160 showed:
e57fed5712fc510c70f47387cdThe 4-vCPU VM did not reproduce a whole-desktop lock, but it reproduced the starvation precursor and the post-#2258 residual hot path. The fixed run completed 145 alternating moves with zero X11 round-trip timeouts; p95 X11 latency was 3.91 ms.
Implementation
Each visible cursor gets a screen-clipped tile with a 64 px margin. Current bloom, pulse, and silhouette effects fit inside that 128×128 area. Every tile composites all cursors so overlapping tiles remain order-independent. XShape replaces the window's visible region on each frame, hiding pixels from old tile positions without a full-root clear.
One tile is 64 KiB of RGBA rather than 63.3 MiB for the tested root. Distant multi-cursor sessions remain separate small tiles rather than becoming one large bounding rectangle.
The original contributor's six commits are preserved with
git cherry-pick -x, and the active-render follow-up retains co-author credit.Validation
cargo test -p platform-linux --libon Linux: 129 passedcargo test -p cursor-overlayon Linux: 12 passedcargo test --workspace --no-runon Linux: passedcargo build -p cua-driveron Linux: passedcargo test -p platform-linux --libon macOS host: 16 passedrustfmt --edition 2021 crates/platform-linux/src/overlay.rs --checkon macOS host: passedgit diff --check: passedxwininfo -shapeafter the fixed run: full overlay geometry remained 7680×2160 while the visible shape was only 24×19 at the cursorThe Azure image's stable Linux toolchain does not include the optional
rustfmtcomponent, so formatting was verified on the exact source from the macOS host. This PR remains draft while CI and review run.