-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Editor video playback performance #1472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
richiemcilroy
merged 14 commits into
recording-benchmark
from
cursor/editor-video-playback-performance-6d4c
Dec 30, 2025
Merged
Editor video playback performance #1472
richiemcilroy
merged 14 commits into
recording-benchmark
from
cursor/editor-video-playback-performance-6d4c
Dec 30, 2025
Conversation
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
Add synthetic recording test framework and improve frame converter reliability
Remove frame padding stripping logic. Update frame processing to use stride and raw data. Improve shared buffer consumer with readInto and slot size. Increase shared buffer slot size. Update WebGPU renderer to use stride for bytesPerRow. Use Arc for decoded frame data to avoid cloning. Co-authored-by: richiemcilroy1 <richiemcilroy1@gmail.com>
|
Cursor Agent can help with this pull request. Just |
Member
Author
|
@greptile review this |
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.
This pull request contains changes generated by a Cursor Cloud Agent
Greptile Summary
Implemented a frame queue system with timing-based playback synchronization to improve video playback performance in the editor. The changes replace the previous single-frame rendering approach with a buffered queue that can hold up to 5 frames, intelligently dropping late frames (>40ms behind) and rendering frames at their target timestamps for smooth playback.
Key improvements:
watchchannel withmpscchannel for better throughput (8-frame buffer)borrow()andreadInto()methods to SharedArrayBuffer for zero-copy frame accessframe_numberandtarget_time_ns) throughout the pipelineArc::clonein FFmpeg decoder instead of full data copiesArchitecture changes:
resetFrameState()call on project config updates to reset playback timingConfidence Score: 4/5
apps/desktop/src/utils/frame-worker.ts- complex frame timing logic and queue management should be tested thoroughly for edge casesImportant Files Changed
readIntoandborrowmethods for zero-copy frame access, increased retry limit to prevent infinite loopscreate_mpsc_frame_wsfor mpsc channels, extended frame metadata with frame number and target timeRenderedFramefor playback synchronizationSequence Diagram
sequenceDiagram participant Rust as Rust Rendering Pipeline participant WS as WebSocket Server participant SAB as SharedArrayBuffer participant FW as Frame Worker participant SCW as Stride Correction Worker participant Renderer as WebGPU/Canvas2D Renderer participant Canvas as Display Canvas Note over Rust: Decode & render frame Rust->>Rust: Add frame_number + target_time_ns Rust->>WS: Send frame via mpsc channel WS->>SAB: Write frame to shared buffer slot loop Poll Shared Buffer FW->>SAB: borrow() or readInto() SAB-->>FW: Frame bytes (zero-copy) FW->>FW: parseFrameMetadata() FW->>FW: Queue frame with timing info end loop Render Loop (RAF) FW->>FW: Calculate frame timing alt Frame too late (>40ms) FW->>FW: Drop frame from queue else Frame ready to render alt WebGPU path FW->>Renderer: renderFrameWebGPU() Renderer->>Canvas: Display frame FW->>SAB: release() borrowed frame else Canvas2D with stride != width*4 FW->>SCW: Offload stride correction SCW-->>FW: Corrected frame data FW->>Renderer: putImageData() Renderer->>Canvas: Display frame else Canvas2D no correction needed FW->>Renderer: putImageData() Renderer->>Canvas: Display frame end end end