Repository navigation
perf(recording): take the cursor position from the recorder's mouse sample - #2621
Open
celeroncoder wants to merge 1 commit into
Open
celeroncoder wants to merge 1 commit into
celeroncoder wants to merge 1 commit into
Conversation
Contributor
|
@celeroncoder is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
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.
spawn_cursor_recorderkeeps oneDeviceStateand readsget_mouse()from it every tick (about 60/s) for the buttons. It then calledRawCursorPosition::get()for the position, which isDeviceState::new().get_mouse().coords. So every tick built a secondDeviceStateand queried the pointer twice.What that extra
DeviceState::new()costs:XOpenDisplay+XCloseDisplay, so one X connection set up and torn down per tick.assert!sapplication_is_trusted_with_prompt(), so the Accessibility trust check ran every tick.GetCursorPosplus the button polls.Change
RawCursorPosition::from_coords(crates/cursor-capture/src/position.rs).get()calls it and keeps working for thecap-cursor-capturebinary.spawn_cursor_recorderbuilds the position from theMouseStateit already has, in all three places: the initial sample, the waiting-for-start-gate branch and the per-tick sample.Positions come from the same source as before. On Linux both handles run
XQueryPointeron the default root ofXOpenDisplay(NULL). On macOS and WindowsDeviceStateis a unit struct and the position isreadmouse::Mouse::location()/GetCursorPos. The only difference is that position and buttons now come from one sample instead of two taken microseconds apart.Results (Linux X11)
main@ 83237e9connect()per tick, moving pointerThe real
spawn_cursor_recorderran for 10 s from release builds of both commits against Xvfb 1920x1080 on a shared 2 vCPU aarch64 VM. CPU is the recorder's user+sys fromgetrusage, median of 5 interleaved runs with the range in brackets. Connection counts come from one strace run, with the startup connections subtracted.macOS and Windows weren't built or measured. The code there is the same platform-neutral change, and on macOS it removes the per-tick Accessibility check.
Overlap
last_mouse_statewithlast_buttons. If both land, the twolast_positionlines becomeRawCursorPosition::from_coords(device_state.get_mouse().coords).cursor.rshunks apply cleanly on top of this.How this was made
This PR is agent-generated.
space-bunny-free(OpenCode) found this during an audit of the repo and wrote the first patch.mainand took the measurements above with a probe that drives the real recorder.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
The recorder now takes cursor coordinates from its existing mouse sample instead of creating another
DeviceState.Reviews (1) · Last reviewed commit: "perf(recording): take the cursor positio..." · Reviewed by Greptile