Skip to content

perf(recording): read the cursor image only on ticks that record an event - #2728

Merged
richiemcilroy merged 1 commit into
mainfrom
perf/cursor-lookup-on-events
Oct 20, 2026
Merged

richiemcilroy merged 1 commit into
mainfrom
perf/cursor-lookup-on-events

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

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)

Per tick Before After (no event)
NSCursor.currentSystemCursor + TIFFRepresentation 546 µs, 583 KB TIFF built, copied and compared skipped
At 62 ticks/s with the pointer still ~34 ms/s of CPU (~3.4% of a core), ~36 MB/s copied and compared ~0

A 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 new button_changes_match_the_pairs_clicks_are_built_from test pins the helper to exactly the button pairs the click loop compares.

RetriggerView in GreptileConfidence 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.

  • Quiet cursor ticks reuse the last cursor id.

Reviews (1) · Last reviewed commit: "perf(recording): read the cursor image o..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cap-status Ready Ready Preview Oct 20, 2026 4:04am UTC

@capy-ai capy-ai 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.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

This branch was successfully deployed

2 active deployments
Preview – cap-web — 0b427953 Deployed Oct 20, 2026 by vercel[bot]
Preview – cap-status — 0b427953 Deployed Oct 20, 2026 by vercel[bot]
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