Skip to content

perf(egui): present only what a glass layer frame changed - #148

Open
klNuno wants to merge 2 commits into
mainfrom
perf/2.0.2-glass-layer
Open

klNuno wants to merge 2 commits into
mainfrom
perf/2.0.2-glass-layer

Conversation

@klNuno

@klNuno klNuno commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Note

Clanker Claude Opus 5.5 is responding on behalf of meetsu

Summary

Hovering a card in Glass Dark no longer copies the whole window every frame: the glass layer keeps its frame between frames and only the tiles that changed reach the window, with no visible change.

what changed

  • compose_backdrop keeps the layer frame, recopies only dirty tiles and the areas a layer touched this frame or the previous one, and presents only that damage (vendor/egui_software_backend/src/lib.rs).
  • The first layer's blur reruns only when its key, the primitives under its box or a dirty tile under it change (blur_fingerprint, dirty_under).
  • compose_filter is incremental while the filtered input stays the same.
  • When a layer leaves, only the area it covered is redrawn.
  • The full root composite runs only when an overlay has a backdrop (keep_root_frame, soft/paint.rs).

to question

CPU time per hover frame does not move: rasterizing dominates, the copies were small next to it. The gain is the bytes handed to the window each frame (-81 %), which the compositor no longer takes in whole.

verified

  • Pixel comparison, 406 captures over 125 glass scenes (120 Glass Dark, 5 Liquid Glass), before vs after, against two renders of main for noise: max MAE 0.622 vs 0.874 noise, worst 16x16 tile 20.71 vs 20.71. The 35 card-hover captures are identical to the pixel. 7 captures exceed their own noise by 1 level on a few text edges: list-glass-dark-150 has no glass layer and main produces the same variant under load; armed-glass-dark-150 renders identical when run alone; onboarding-deal persist-error matches the main-vs-main gap (27 levels).
  • Hover bench, 120 measured frames: pixels handed to the window 378,400 -> 70,152 at 100 %, 851,400 -> 157,509 at 150 %; median CPU 1.43 -> 1.44 ms at 100 %, 3.26 -> 3.12 ms at 150 %.
  • New test a_hovered_glass_card_presents_only_what_changed fails on main (a still hover presented 378400 of 378400 pixels) and passes 6 of 6 after; it compares each partial window to a fresh full render. Vendor test a_still_layer_copies_only_what_changed passes (window equals a fresh render, blur not rerun for a hover outside the box, window restored when the layer leaves).
  • not verified: a visible window (hidden harness and tests only); Liquid Glass off the UI thread during resize was not attempted; a cached render can differ from a fresh one by 1 level on 3 pixels, as main already does in 1 run of 6, so the test allows 2 levels per channel.
  • build-safe node scripts/gates.mjs passed 7/7 gates on Windows, including 407 egui and 22 software renderer tests.
  • Two regressions fail before the fixes and pass after: a two-buffer swap left 19,788 stale pixels, and an overlap reorder reused the previous blur.
  • After the fixes, 35 card-hover and keyboard-focus captures are byte-identical to the first matching baseline batch.
  • Softbuffer 0.4.8 returns age 1 after a Win32 present. AppKit returns 0 and Wayland swaps age-2 buffers, so those keep full window copies.
  • reviewed by GPT-6.2 Sol: 2 rounds, approved.

Related issue

None.

Tested on

  • Windows
  • macOS
  • Linux

Checklist

  • CI checks pass locally (see CONTRIBUTING.md)
  • Docs or wiki updated if the change is user-facing (rendering is visually unchanged)
  • No secrets, session tokens or captured account data in the diff

A hovered glass card copied the whole canvas into the layer frame, then
that frame into the window, and composited the root frame in full, on
every frame. The layer frame is now kept: only the dirty tiles and the
regions the layers and the jobs after them touched, this frame or the
last, are copied and drawn again, and only those reach the window. When
the layer goes, the window takes back the regions it covered instead of
the whole canvas. The first layer's blur is redone only when its key,
the primitives under its box or a tile under it change, and the root
frame is composited only while an overlay's backdrop reads it.

Hovering a glass card for 120 frames presents 70 152 of 378 400 pixels a
frame at 100 % and 157 509 of 851 400 at 150 %, against all of them.
A window buffer only holds the last frame at softbuffer age 1; Wayland
swaps two, so at age 2 a partial copy left the old card's glass behind.
Any other age now gets every pixel.

The first layer's blur fingerprint summed its primitives' hashes, so two
overlapping shapes that swapped kept the old blur. It now folds them in
paint order.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 095d5cd4-a084-4432-9905-1c3e5fbb860d
Commits

Reviewing files that changed from the base of the PR and between 1891f4e and 9491e5a.

Files selected for processing: 4

  • crates/accshift-egui/src/soft/paint.rs
  • crates/accshift-egui/src/soft/present.rs
  • crates/accshift-egui/src/soft/tests.rs
  • crates/accshift-egui/vendor/egui_software_backend/src/lib.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mtsu-patrol mtsu-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

@mtsu-patrol

mtsu-patrol Bot commented Nov 23, 2026

Copy link
Copy Markdown

Hovering a glass card now updates only the regions that changed instead of copying the whole window on every frame. The window buffer is reused when it still holds the previous frame, and the blurred background work is skipped when no overlay needs it. The picture shown stays the same.

No comments posted: the reviewers raised no finding.

Review details
  • Model: muse-spark-1.3-contributor
  • Compared commits: 1891f4e to 9491e5a
  • Execution: tests could run in a disposable Linux sandbox
  • Files reviewed: 3 of 4
  • Duration: 3 min 3 s
Files skipped (1)
  • crates/accshift-egui/vendor/egui_software_backend/src/lib.rs: vendored or build output
Commands run (11)

Ran x1-x6 discovery (repo layout, Cargo members, soft tests: a_hovered_glass_card_presents_only_what_changed, swapped_window_buffers_keep_no_old_card, vendor a_still_layer_copies_only_what_changed) and x7-x10 toolchain checks: cargo/rustc absent, no /opt or cargo dirs, curl+python available, /tmp 16G, /work 2.3G free. x11 downloaded rustup.sh but budget expired before installing Rust, so no build, no cargo test, and no app exercise were run. No failures reproduced.

passed · exit 0 · 0 s

ls -R | head -n 100; echo "---"; cat package.json 2>/dev/null | head -n 80; echo "---"; cat crates/accshift-egui/Cargo.toml 2>/dev/null | head -n 60; echo "---"; git log --oneline -5; echo "---"; git diff --stat HEAD~1 2>/dev/null || git diff --stat origin/main 2>/dev/null || git status --short | head -n 30

passed · exit 0 · 0 s

cat README.md | head -n 120; echo "==="; cat .github/CONTRIBUTING.md 2>/dev/null | head -n 150; echo "==="; cat scripts/gates.mjs 2>/dev/null | head -n 150

passed · exit 0 · 0 s

git diff --stat HEAD~1 2>/dev/null || git diff --stat HEAD 2>/dev/null || git log --stat -1 --oneline | head -n 50; echo "==="; git show --stat HEAD | head -n 40

passed · exit 0 · 0 s

git diff --stat 1891f4e55707c6c7274ef890f249e0b76a0d96d4..HEAD | head -n 30
echo "==="
git log --oneline 1891f4e..HEAD | head -n 20

passed · exit 0 · 0 s

ls crates/accshift-egui/src/soft/; echo "==="; cat crates/accshift-egui/Cargo.toml | head -n 80
echo "==="; ls crates/accshift-egui/vendor/egui_software_backend/
echo "==="; cat Cargo.toml | head -n 60

passed · exit 0 · 0 s

grep -n "^fn \|^pub fn \|#\[test\]\|fn a_" crates/accshift-egui/src/soft/tests.rs | head -n 60
echo "==="
grep -n "#\[test\]\|fn a_\|fn test" crates/accshift-egui/vendor/egui_software_backend/src/lib.rs | head -n 60

failed · exit 127 · 0 s

cargo test -p accshift-egui --lib soft::tests::a_hovered_glass_card_presents_only_what_changed -- --nocapture --test-threads=1 2>&1 | tail -n 60
/bin/bash: line 1: cargo: command not found

failed · exit 1 · 0 s

ls ~/.cargo/bin/ 2>&1; echo "==="; ls /usr/local/cargo/bin/ 2>&1; echo "==="; which rustc 2>&1; ls /opt/ 2>&1; echo "==="; find / -maxdepth 5 -name cargo -type f 2>/dev/null | head
ls: cannot access '/work/.patrol-home/.cargo/bin/': No such file or directory
===
ls: cannot access '/usr/local/cargo/bin/': No such file or directory
===
/bin/bash: line 1: which: command not found
ls: cannot access '/opt/': No such file or directory
===

failed · exit 1 · 0 s

echo $PATH; echo "==="; ls /usr/local/bin/ 2>&1 | head -n 50; echo "==="; ls / | head -n 30; echo "==="; find / -maxdepth 6 -name "cargo" 2>/dev/null | head -n 20
/usr/local/bin:/usr/bin:/bin
===
bun
node
npm
npx
patrol-smoke
patrol-smoke.bak-20261001-app
patrol-smoke.bak-20261002-finalization
patrol-smoke.bak-20261007-engine2
patrol-smoke.bak-20261008-incremental
patrol-wait-network
===
bin
dev
etc
lib
lib64
proc
sbin
tmp
usr
work
===

failed · exit 2 · 0 s

cat /etc/os-release; echo "==="; curl --version 2>&1 | head -n 3; wget --version 2>&1 | head -n 3; python3 --version 2>&1; echo "==="; df -h 2>&1 | head; echo "==="; env | grep -i -E "home|cargo|rust" 2>&1; echo "==="; ls -la /work/.patrol-home/ 2>&1 | head -n 20
cat: /etc/os-release: No such file or directory
===
curl 8.5.0 (x86_64-pc-linux-gnu) libcurl/8.5.0 OpenSSL/3.0.13 zlib/1.3 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 (+libidn2/2.3.7) libssh/0.10.6/openssl/zlib nghttp2/1.59.0 librtmp/2.3 OpenLDAP/2.6.10
Release-Date: 2023-12-06, security patched: 8.5.0-2ubuntu10.16
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
GNU Wget 1.21.4 built on linux-gnu.

-cares +digest -gpgme +https +ipv6 +iri +large-file -metalink +nls 
Python 3.12.3
===
Filesystem                        Size  Used Avail Use% Mounted on
tmpfs                              16G     0   16G   0% /
/dev/mapper/pve-vm--121--disk--0  7.8G  5.1G  2.3G  69% /usr
tmpfs                              16G     0   16G   0% /dev
tmpfs                              16G     0   16G   0% /tmp
===
HOME=/work/.patrol-home
===
ls: cannot access '/work/.patrol-home/': No such file or directory

passed · exit 0 · 0 s

mkdir -p /work/.patrol-home && df -h /work /tmp 2>&1 | head; echo "==="; curl -sSf https://sh.rustup.rs -o /tmp/rustup.sh && ls -lh /tmp/rustup.sh && head -n 5 /tmp/rustup.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant