Repository navigation
#329: scrubbing a long movie: superseded viewer frames call off their decodes - #784
Merged
Merged
Conversation
Problem: scrubbing a long movie showed the frame under the pointer seconds after the pointer stopped. Every viewer frame a free frame-pool thread had started kept running: each seeked the movie's one decoder and decoded up to a GOP, and the newest frame waited behind all of them on the decoder's lock (45 min 1080p H.264/HEVC, GOP 250: 1.8-3.6 s for the last frame of a drag; a single jump is 0.1-0.4 s). FilmCraft's decoder already polls a cancellation flag, but nothing set one. Fix: FootageSource::cancellable / called_off and CancellableFootage (a per-render view whose frame reads run under the render's own flag, so reads on other threads answer to the right render). MediaPool runs them under filmcraft_media::cancel::with_cancel. The frame workers render through it, and a newer viewer frame calls off the comp's running viewer frames of other times. A called-off render is not cached (frames, disk, layer cache). Drag latency is now 0.1-0.3 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Extra verification: since this changes the |
This was referenced Oct 11, 2026
This was referenced Oct 11, 2026
eliasx45
pushed a commit
to eliasx45/effectcraft
that referenced
this pull request
Oct 11, 2026
…first (storytold#595) Ports the still-needed part of upstream PR storytold#793 onto the fork's protected window (fdafa81): - Frames::set_playhead (set by playback every UI frame, cleared on stop and while scrubbing): while a preview plays, eviction takes frames it doesn't reach first, then the one it reaches last, instead of LRU outside the small protected window. A looping preview longer than the cache re-rendered every frame on every loop (60 renders in 3 laps of 20 frames with 8 cached; now 47). - Prefetch order: urgent, then the frame the preview reaches first, then request order, disk-only last; queued prefetch frames of the playing series it no longer reaches are dropped and leave the in-flight set. - The playback prefetch window stops at what the RAM preview holds. Not ported: storytold#793's viewer Arc sharing (fork already has fit_texture_shared) and the media/render footage cancellation (storytold#784, separate). Tests run: cargo test -p effectcraft-ui-egui --lib frames::tests (25 ok, 3 new: a_full_cache_keeps_the_frames_just_ahead_of_the_playhead, a_looping_preview_longer_than_the_cache_renders_only_what_does_not_fit, prefetch_renders_the_frames_the_playhead_reaches_first; all 3 failed before), playback_budget/playback_pacing lib tests (11 ok); clippy -D warnings on effectcraft-ui-egui --all-targets.
Member
|
Merged. Thank you for the contribution, @vangel76! If you haven't already, come join us on Discord: https://discord.gg/artcraft. It's the best place to discuss what you're working on next and to coordinate with other contributors. |
h-a-n-a-s-h-i
pushed a commit
that referenced
this pull request
Oct 12, 2026
- Footage sources: the cancellable wrapper (#784) forwards frame_with (#752 float curves) and problem (#887); problem's default lives on the trait. - Media: a called-off decode (#784) is not a footage problem (#887). - Effect Controls rename (#953): Escape cancels (egui drops focus on Escape the same frame), the Rename item is translated; regression test. - i18n (#873): drop the /out-i18n/ ignore rule and the note about an uncommitted script. - Tests: text range selector caps (#926) re-borrow the layer; the RAM preview test (#793) sets the comp's own Resolution (#462). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eliasx45
pushed a commit
to eliasx45/effectcraft
that referenced
this pull request
Oct 12, 2026
…ng a long movie shows the frame under the pointer quickly (storytold#329, port of upstream storytold#784)
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.
Fixes #329.
Problem
Scrubbing a long movie (dragging the current-time indicator or clicking around a 45 min clip) showed the frame under the pointer only seconds after the pointer stopped.
A single far jump is not the slow part: FilmCraft's GOP cache seeks to the preceding keyframe and decodes forward from there (one keyframe-to-target run per jump, 0.1–0.4 s here). The time goes into superseded viewer frames. While dragging, the viewer asks for a new frame every UI frame. Queued requests were already dropped (#284), but each request that a free frame-pool thread had started kept running: it seeked the movie's one decoder and decoded up to a whole GOP, and the frame the pointer stopped on queued behind all of them on the decoder's lock. Nothing in EffectCraft used FilmCraft's cooperative cancellation (
filmcraft_media::cancel), although the decoder already checks it before a seek and between samples.Fix
effectcraft-render:FootageSource::cancellable(cancel, f)(default: just runsf) andFootageSource::called_off(), plusCancellableFootage, a per-render view of a source whoseframe/frame_at_sizereads each run insidecancellablewith the render's own flag. The flag travels with the render's footage reference, not with the thread, so reads made for the render on other threads (parallel loops) answer to it and reads for other renders never do. A render whose reads were called off keeps nothing in the layer cache (an effect's layer parameter could otherwise cache a layer made from a frame that came back empty).effectcraft-media:MediaPoolimplementscancellablewithfilmcraft_media::cancel::with_cancel; a called-off read isMediaError::Cancelled(not logged as a decode error, not cached).effectcraft-ui-egui(frames.rs): every frame job carries a cancel flag and renders throughCancellableFootage. A new viewer (urgent) frame calls off the comp's running viewer frames of other times (another revision of the same frame, a live edit, still finishes, as the viewer shows it meanwhile). A called-off render is released without being cached (RAM or disk), and the viewer asks again if it still wants it.Prefetch, RAM preview and playback read-ahead jobs are never called off.
Measurements
Generated 1080p30
testsrc2clips at 900 kb/s (x264superfast -bf 3, x265ultrafast). Measured throughMediaPool(the viewer's decode path) with a throwaway example (not committed). Machine: AMD Ryzen, 16 threads, Linux, shared with other builds (load average ~20). Ranges are over repeated runs.Single jumps (unchanged by this PR; mean over 12 random far jumps):
-ss t -frames:v 1(incl. ~80 ms process start/open)Scrub (20 viewer requests 16 ms apart, each started on its own thread as the frame pool does; latency = last request until its frame):
After the fix, the frame under the pointer costs about one keyframe-to-target decode, as for a single jump.
Not changed here (FilmCraft codec side, for a follow-up there): a far jump still decodes up to a whole GOP. FilmCraft's HEVC decoding is about 2× slower than ffmpeg's per jump on these clips. Footage is also read whole into memory when it is opened (
probeand the first frame of a file).Tests
effectcraft-ui-eguiframes::tests::a_newer_viewer_frame_calls_off_the_one_rendering: a viewer frame stuck in a long seek is called off by a newer viewer frame of another time, is not cached, and the newer frame renders. Without the fix it fails: the old render runs its full 5 s and gets cached.effectcraft-mediatests/footage.rs::a_called_off_read_does_not_decode: a called-offMediaPoolread returns no frame and caches nothing, and the frame decodes normally when it is wanted again. Fails without the fix.effectcraft-rendertests::a_called_off_render_keeps_nothing_in_the_layer_cache.Gates
cargo fmt --check;cargo clippy -D warnings --all-targetsfor render, media and ui-egui; full tests ofeffectcraft-render,effectcraft-mediaandeffectcraft-ui-egui(--no-fail-fast);cargo xtask layers;cargo check --target wasm32-unknown-unknownfor render and media. I did not run the fullcargo xtask cibecause the machine is shared.🤖 Generated with Claude Code