Repository navigation
perf(editor): keep rendered playback audio across pause and play - #2521
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Member
Author
|
hey @greptileai, please re-review the PR |
Member
Author
|
hey @greptileai, please re-review the PR |
Member
Author
|
hey @greptileai, please re-review the PR |
Member
Author
|
hey @greptileai, please re-review the PR |
Member
Author
|
hey @greptileai, please re-review the PR |
This was referenced Oct 19, 2026
…-audio-prerender # Conflicts: # crates/editor/src/lib.rs
…heck the playback cache before building a fresh render
Member
Author
|
@greptileai review (fixed the merged-in rendered() field access, and cache hits are now looked up before a fresh render is allocated) |
Member
Author
|
@greptileai review |
This comment has been minimized.
This comment has been minimized.
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.
On
main, every Play renders the whole timeline mix again from 1 s before the playhead, then wraps to the start (crates/editor/src/audio.rs). Pausing drops the buffer, so the next Play repeats the same work. This PR replays the previous render on the next Play, but only when that provably gives the same samples a fresh render would.flowchart TD Play[Play at P] --> Fresh[spawn main's render from P - 1 s<br/>exactly as on main] Fresh --> Check{origin independent project,<br/>key matches cache, cache already covers<br/>P - 1 s .. P + 0.25 s?} Check -- yes --> Replay[read the cached render,<br/>stop the fresh one] Check -- no --> Keep[play the fresh render] Keep --> Retain{origin independent<br/>and start rounds down?} Retain -- yes --> Cache[fresh render becomes the cache entry;<br/>old entry freed once it finishes or parks] Retain -- no --> Done[main behaviour] Pause[Pause] --> Park[cached render parks with its state] Idle[2 min paused, export, memory pressure,<br/>output stream dropped] --> Free[cache released]When a replay is allowed
render_is_origin_independent(audio.rs:1972) requires every stage between the sources and the buffer to be stateless, so each sample is a pure function of its timeline position:maingives position-dependent samples.Otherwise the Play runs
main's code unchanged and the cache entry is dropped.Why replayed samples match a fresh render
main's pass 1 writes into slotfloor(O * 48000)while the renderer starts at source sampleround(O * 48000). So a render from originOholdsv(f + d)in every slotfof pass 1, wheredis 0 or 1, andv(f)in the wrap pass. The cache only keeps renders withd = 0, which holdv(f)everywhere. A replay withd = 1reads one frame ahead from its own pass 1 start (origin_shift,audio.rs:2008):Other details
main. A hit needs the cached render to already cover whatmainwould have rendered at ready time (covers,audio.rs:1548), from 1 s before the playhead to 0.25 s after it.audio_project_key,audio.rs:1901): track and music identity, output format, duration, and the serialized audio inputs (audio,clips, timeline segments, transitions, music segments, hold windows).ProjectConfigurationandTimelineConfigurationare destructured without.., so adding a field fails to compile until someone decides whether it affects audio. Visual edits (zoom, background, captions, clip names) keep the cache.PLAYBACK_AUDIO_IDLE_RELEASE), before exports (release_playback_audio_caches), on macOS memory pressure, and when the output stream drops. A replaced entry is freed once the next render finishes or parks, never while playback is starting.Results
M4 Max under shared load (load average 15 to 100), runs interleaved with
mainand a secondmainrun as an A/A control, 20 to 24 rounds per case. Harness:PrerenderedAudioBufferwith 512-frame real-time pulls, plusAudioOutput::new_headlessfor the output path.Replay (cache hit), Studio Sound off
main→ PRmain→ PRmain→ PRFirst Play, plays after an audio edit, and Studio Sound on (cache miss). These run
main's code. Across 104 interleaved timing cases (audio ready and first audible block), none is significantly slower thanmain(Mann-Whitney p < 0.05). The A/A control missesmain's own median and p95 more often than the PR does.Audio: 2,696 plays compared sample for sample. They covered play from start, fractional start positions, pause and play, near end, seeks during play, every edit type in the editor (split, delete, reorder, trims, clip/mic/system volume and mute, stereo mode, offsets, isolation, speed in three modes, transition, text hold, music and music volume, Studio Sound toggle, and visual edits), Studio Sound on and off, and 60 s and 10 min projects. All are identical to
main, except three seeks into audio a Studio Sound render had not reached yet. There, both sides playmain's code and differ only in how long the silence lasts, which varies run to run onmaintoo (A/A: 853 vs 75 ms, 203 vs 1003 ms).Memory while paused (Studio Sound off): 60 s 19 → 40 MB, 10 min 308 → 528 MB, back to
mainafter the idle release. With Studio Sound on nothing is cached and footprint matchesmain.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was found.Summary
The PR keeps eligible rendered audio across pause and play.
Reviews (10) · Last reviewed commit: "fix(editor): read the progressive render..." · Reviewed by Greptile