Repository navigation
Conversation
Contributor
|
@flamboh is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
Member
|
Thanks for the PR. Greptile's 5/5 was for 7a7ab58, and new commits have landed since, so the current head hasn't been scored. We only merge once the current head is 5/5. Please comment |
Contributor
Author
|
@greptileai review |
Contributor
Author
|
@richiemcilroy greptile 5/5! thanks for making awesome software |
…cache # Conflicts: # apps/desktop-gpui/kernels/src/lib.rs
Contributor
Author
|
@greptileai review |
This branch has not been deployed
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.
Note
🤖 GPT-6 Astra and Claude Opus 5.5 on behalf of Oliver
Problem and change
Dragging one screenshot privacy mask currently rebuilds the filtered images for every mask and drops every previous overlay from the GPUI atlas. This caches completed results per annotation, so moving one mask filters one region and preserves the other masks'
Arc<RenderImage>values.Cache keys include an explicit source-frame revision, frame dimensions, the clipped integer pixel region, mask type, effective level, content rectangle, crop, and padding. Cached entries are matched one-to-one (exact request first, then annotation ID), so duplicate annotation IDs never share or lose an image. Results remain in annotation order. Removed masks are evicted immediately; an atlas image is dropped only when no replacement overlay still references it. Pending work is cancelled on changed requests, including deletion and returning to an already-cached position, and the completion-time refresh remains in place.
While a build is in flight, move/level/type/add/reorder requests no longer cancel it: the build completes, installs (reconciled one-to-one against the current overlays), and the completion-time refresh then builds the latest state, so at most one build runs and at most one latest request waits. Previously every drag tick dropped the in-flight build, which at drag rates could starve installation for up to a second. Removals, delete-all, frame revision/size, crop, padding, content-rect changes and ambiguous duplicate-ID changes still cancel immediately, so a removed mask can never be re-installed by a late build.
The cache matching and clipping logic live in a GPUI-free module in
cap-gpui-kernels. The filtering kernel, image quality, and export behavior are unchanged.In the running editor
On
main, dragging a privacy mask with many masks on screen leaves its blur behind: the selection handles move, but the filtered overlay stays at the old position for up to a second, leaving the text under the mask's new position readable. Same 16-mask drag, recorded from the GPUI editor at 120 Hz (the dragged mask moves from the inbox card onto the chat message):https://gh-file-drop-api-prod-galwoqjslzlnws6s.oliver-boorstein.workers.dev/f/a83638863c41a4ee/before-after-blur-16.mp4
https://gh-file-drop-api-prod-galwoqjslzlnws6s.oliver-boorstein.workers.dev/f/4107f50f7167c51e/before-after-pixelate-16.mp4
Measured in the release GPUI app (M4 Pro, macOS 27.2) with temporary, uncommitted instrumentation: a driver calls the editor's real move/mouse-up handlers for 120 ticks at 120 Hz on a 3840×2160 screenshot with 640×360 masks, 3 runs per configuration. Catch-up is request → first GPUI paint showing overlays at least that new; the max gap is the longest stretch of the drag with no overlay installed.
main→ this PRmain→ this PRmain→ this PRAcross all 12 configurations (blur/pixelate/mixed × 1/4/8/16) the longest gap is now ≤ 52 ms versus up to ~1 s on
main. The trade-off is at one mask, where there is nothing to cache: a request that arrives mid-build now waits for that build instead of restarting, so mean catch-up rises (e.g. 5.8 → 20.2 ms for pixelate) while p95 stays ≈ 35 ms and the longest gap is unchanged. Identical one-mask configurations varied 8–25 ms between runs, so part of that is scheduling noise.Also exercised in the running editor: deleting a mask while a build containing it is executing (its region is never re-installed across 117 subsequent paints), delete/undo/redo, crop, padding and delete-all mid-drag, duplicate annotation IDs (never fewer overlays than masks on any paint), atlas retirement (0 of 1,021 dropped images still referenced), and a 600-tick drag holding exactly 16 live mask images. The harness bypasses OS input, hit testing and pointer capture.
CPU microbenchmark
Drag one mask among N on a deterministic 3840×2160 RGBA screenshot: 640×360 masks, level 16, 120 measured drag events after 12 warmup pairs, before/after order alternated. "Before" reproduces the old builder exactly (overlay images and geometry only); every overlay's geometry and bytes are compared against it after every event, outside timing. Numbers are CPU overlay preparation per drag event (filtering, cache matching, allocation, retired-image release); they exclude GPUI scheduling, atlas upload and painting.
Mean ms per drag event, before → after:
Repeat runs on both machines were within a few percent (M4 Pro 16-mask blur 15.5–15.9×; Ryzen 16.7–16.9×). One mask is the control: there is nothing to reuse, so it should not change. Frame replacement invalidates every mask and is not expected to benefit. On the Ryzen, 16 blur masks previously cost ~81 ms of preparation per drag event.
Reproduce
From
apps/desktop-gpui(GPUI workspace):Without the GPUI/FFmpeg toolchain (e.g. on Linux), from the repository root:
The standalone package compiles the production
mask_cache.rsand screenshot-kernel sources and depends only onimage, at the version in the desktop lockfile.Validation
From
apps/desktop-gpuion macOS (Rust 1.97.0):cargo fmt --all: clean.cargo check --all-targets: passes.cargo test -p cap-gpui-kernels: 34 passed, 1 ignored.cargo test -p cap-desktop-gpui --bin cap-gpui -- screenshot mask: 60 passed, 1 ignored, including a regression test for duplicate IDs + deletion + reordering + retirement against real GPUI images.cargo clippy -p cap-gpui-kernels --all-targets -- -D warnings: clean. Workspacecargo clippy --all-targets -- -D warningsreports nothing in files touched here; its only failures are existing lints in untouched files onmain(e.g.diagnostics.rs,editor_timeline.rs,updates.rs).cargo test -p cap-gpui-kernels42 passed;cargo test -p cap-desktop-gpui --bin cap-gpui -- screenshot mask61 passed; no clippy diagnostics in touched files.Cache tests cover coalesce-vs-cancel decisions, moving one of N masks, deletion, reordering, overlaps, duplicate IDs, level/type changes, frame/crop/padding invalidation, fractional/clipped rectangles, and identical requests.
Related work
#2529 optimizes screenshot-export/frame kernels; #2493 targets unannotated exports; #2490 scissors GPU video-mask draws. This change targets the GPUI screenshot editor's per-mask overlay cache.
Implemented with GPT-6 Astra (Codex harness), reviewed by GPT-6.1 Sol, and measured in the running app by GPT-6.1 Sol, and validated with Claude Opus 5.5 (Claude Code) in T3 Code.


Confidence Score: 5/5
The PR appears safe to merge; no actionable defects were found.Summary
This PR caches completed screenshot masks separately, so changing one mask can reuse the others.
No actionable new issues were found. The previous and current commits have different merge bases with the target commit, so this review covered the full PR diff. No previous review threads were supplied. Checks were based on code inspection; builds and UI checks were not run.
Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile