Repository navigation
perf(recording): read the cursor image only on ticks that record an event - #2728
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully 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.
What
The cursor recorder ticks every 16 ms for the whole recording. On every tick it asked AppKit for the current cursor and built
TIFFRepresentation()of its image, then copied it and compared it byte for byte with the previous tick's.That image is only used to label the move and click events recorded on that tick. On a tick where the pointer didn't move and no button changed (most of a typical recording: talking, typing, reading), the result was thrown away.
The recorder now reads the cursor image only when the tick records a move or click, or when it has no cursor id yet. Keyboard sampling, the 16 ms cadence, flushes and every recorded event are unchanged. Each event still carries the cursor image from its own tick, exactly as before.
The only output difference: a cursor shape that appears and disappears while the pointer is perfectly still and no button changes is no longer saved as an unused
cursor_N.png. Nothing referenced those files.Cost removed (M4 Max, macOS 27, same AppKit calls as
get_cursor_data, 300-call average)NSCursor.currentSystemCursor+TIFFRepresentationA Studio recording was measured at ~5.7% CPU in-process on a static screen, so this was a large share of the recorder's idle cost. Ticks with movement are unchanged.
Tests
cargo test -p cap-recording --lib cursor::: 14 pass. The newbutton_changes_match_the_pairs_clicks_are_built_fromtest pins the helper to exactly the button pairs the click loop compares.

Confidence Score: 5/5
The PR appears safe to merge; recorded move and click ticks still request a fresh cursor image.Summary
The recorder skips cursor-image reads on ticks without movement or button changes once it has a cursor ID.
Reviews (1) · Last reviewed commit: "perf(recording): read the cursor image o..." · Reviewed by Greptile