feat(studio): frame prefetch window with generation-keyed cache#68
Merged
Conversation
Preview frames are now pre-rendered ahead of the playhead instead of strictly on demand: - StudioModel.scenario/tasks become Arc snapshots — no rendering ever happens under the model lock anymore (frame handler, hit-map, baseline and diff paths all clone Arcs under a brief lock and render outside it) - bounded frame cache (120 JPEG entries) keyed (generation, side, frame); side A keys on the baseline source hash so watcher reloads keep A-frames warm while Set-baseline invalidates them - background prefetcher thread polls a published target and keeps [cur..cur+30] warm while playing, [cur-5..cur+30] while paused, nearest-first, aborting the pass as soon as the target changes; an edit bumps generation, stale keys are purged on insert and the window re-renders — cache hits serve bytes with zero lock and zero render
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.
Closes #67.
Goal: fluid preview — pre-render N frames ahead of the playhead into a bounded cache, re-primed on every modification, instead of rendering each displayed frame on demand.
StudioModel.scenario/tasksbecomeArcsnapshots — no rendering under the model lock anywhere anymore (frame handler, hit-map, baseline/diff paths); in-flight renders keep the old snapshot alive across reloads(generation, side, frame); eviction purges stale generations first (only for sides whose expected generation is known — the inactive side is never wrongly purged), then farthest-from-playhead. Accepted agent refinement: side A keys on the baseline source hash, so watcher reloads keep A-frames warm and Set-baseline invalidates them{current, playing, generation, side, Arcs}; window[cur..cur+30]playing /[cur-5..cur+30]paused, nearest-first with forward tie-break, pass aborted the instant the target changes; per-frame catch_unwindTests: 12 new (TDD red-first): exact nearest-first ordering, boundary clamps, stale-generation-first eviction incl. the unknown-side guard, distance eviction, bounded cache with side separation. 357 total, all green.
Verify:
cargo check -p rustmotion-studio✓ ·cargo test --workspace→ 357 passed ✓ ·cargo fmt --check✓ · clippy gated ≤1 ✓