Repository navigation
perf(rendering): precompute cursor spring for preview/thumbnail - #3225
Merged
richiemcilroy merged 1 commit intoOct 25, 2026
Merged
Conversation
Export preview and the editor thumbnail were still calling ProjectUniforms::new, which rebuilt the cursor spring on every sample. Build PrecomputedCursorTimeline once and pass it through, and intern cursor ids during that build.
Contributor
|
@kyzer1023 is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
@greptileai review |
This was referenced Oct 25, 2026
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
Export preview (
crates/export/src/preview.rs) and the editor thumbnail (crates/editor/src/thumbnail.rs) now build aPrecomputedCursorTimelineonce and pass it toProjectUniforms::new_with_precomputed_cursor. Playback and main export already did this. Preview and thumbnail were still callingProjectUniforms::new, which rebuilds the cursor spring on every sample.PrecomputedCursorTimeline::from_projectuses the base cursor spring (tension, mass, friction, click spring). Per-frame style overrides still go through the existingcached_variantpath insidenew_with_precomputed_cursor. A transition reuses that timeline when both sides are the same recording clip, and builds a second timeline when the outgoing clip is different.The one-time spring build also interns cursor ids. Each 60 Hz simulation step stores a
u32instead of cloning aString. Interpolation still returns the same cursor id string.Why
interpolate_cursor_with_click_springfilters, decimates, and runsbuild_smoothed_timelineon every call.ProjectUniforms::newinvokes that closure at least three times per frame (current position, previous position, and tilt) plus click ripples. Preview and thumbnail paid that cost on every frame even though the spring does not depend on the frame.Bench
From bc-50d9e482 scan #4, three uncached rebuilds versus one indexed build:
A local debug check of the same shape (unoptimized; the precomputed side includes the one build plus three lookups) was 4.984 ms → 1.534 ms for 60s/3601 moves, 46.665 ms → 14.694 ms for 10 min, and 274.348 ms → 87.413 ms for 60 min. That run interned the cycling cursor ids down to 3 strings. These debug times are slower than the scan because they include the build and run unoptimized; they confirm the 3× rebuild versus one build ratio.
Overlap
Does not overlap #3144, #3145, #3146, #2980, #2981, #2979, #2809, or #3112. #3112 caches
ProjectConfigurationsnapshots and is complementary: this change only stops the cursor spring rebuild on the export-preview and thumbnail paths.Test plan
cargo fmt --allcargo clippy -p cap-rendering -p cap-editor -p cap-export --all-features --locked --no-deps -- -D warningscargo test -p cap-rendering --lib cursor_interpolation::tests— 20 passed, 2 ignoredcargo test -p cap-editor --lib thumbnail::— 4 passed, 1 ignoredscreenshots/preview.jpgfor a project whose cursor smoothing is on

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Preview and thumbnail rendering now build one cursor spring timeline per rendered frame and reuse it across cursor samples.
Reviews (1) · Last reviewed commit: "perf(rendering): precompute cursor sprin..." · Reviewed by Greptile