Repository navigation
fix(preview): jump-vs-natural seek policy + shared sync helper - #43
Merged
Merged
Conversation
…small previews
The Triage and Arrange small CamPreviews and the editor's VideoElementPool
all wrote `videoEl.currentTime = X` whenever drift exceeded a tight
threshold. On large phone recordings (multi-GB) the browser tears the
decoder open from the nearest keyframe on every write, which on
back-to-back ticks turns into a positive-feedback stutter loop —
"the post-seek stutter loop the user reports".
This change introduces a single jump-vs-natural classification used in
both surfaces:
- `local/timing/cam-preview-sync.ts` (relocated from `components/triage/`):
a pure decision function returning {pause-before-start, pause-after-end,
hold, seek}. A meaningful master jump (chunk click, scrub, loop wrap)
always seeks with a precise 50 ms drift threshold; natural ~16 ms RAF
advance only seeks when drift becomes catastrophic (>500 ms). The
Triage and Arrange CamPreview components now consume this helper.
- `editor/render/video-element-pool.ts`: the editor pool gets the same
policy, plus a mid-seek skip (`v.seeking` → don't write currentTime)
so two-in-flight seeks can't stack on one element.
The pool also resets `prevTargetSourceT` on off-PROGRAM cams so a
re-entry tick is treated as first contact and snaps precisely.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks done
johannboehme
added a commit
that referenced
this pull request
May 9, 2026
#44) * fix(preview): drop seeking-guard that froze playback in Triage + Arrange #43 added a defensive `if (videoEl.seeking) return` guard to the sync effects in both CamPreview surfaces. Intent was to avoid stacking currentTime writes during the 100-400 ms decoder warmup. In practice it broke responsive scrubbing and froze Arrange playback: - Triage: continuous scrubs / loop-wraps land during the previous seek's warmup → guard skips → user sees stale frames jump-cut to catch up = visible "ruckeln". - Arrange: initial play() seeks; while seeking the guard skips every subsequent tick, including the `if (isPlaying && videoEl.paused) play()` recovery path. Browser's seek-implicit pause is never re-played → video frozen. The jump-vs-natural classifier already prevents the original stutter loop (natural advance with a generous 500 ms threshold; only jumps trigger seeks). The seeking-guard was redundant and harmful — browsers handle "newer setCurrentTime supersedes in-flight seek" internally. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix(preview): drop seeking-guard in editor compositor pool too Same bug as Triage+Arrange (3f21766) — the pool's syncSlot had its own `if (v.seeking) return` that suppressed the play() recovery while the browser had implicitly paused the element during a seek. Result: editor preview videos froze on the first seek. The jump-vs-natural classifier already prevents the original stutter loop. Browsers handle a fresh currentTime write supersession during an in-flight seek internally — we don't need the guard. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
The Triage and Arrange small CamPreviews and the editor's
VideoElementPoolall wrotevideoEl.currentTime = Xwhenever drift exceeded a tight threshold. On large phone recordings the browser tears the decoder open from the nearest keyframe on every write — back-to-back ticks turn into a positive-feedback stutter loop.This PR introduces a single jump-vs-natural classification used in both surfaces:
local/timing/cam-preview-sync.ts(relocated fromcomponents/triage/): a pure decision function returning{pause-before-start, pause-after-end, hold, seek}. A meaningful master jump (chunk click, scrub, loop wrap) always seeks with a precise 50 ms drift threshold; natural ~16 ms RAF advance only seeks when drift becomes catastrophic (>500 ms). The Triage and ArrangeCamPreviewcomponents consume this helper.editor/render/video-element-pool.ts: the editor pool gets the same policy, plus a mid-seek skip (v.seeking→ don't write currentTime) so two-in-flight seeks can't stack on one element. Also resetsprevTargetSourceTon off-PROGRAM cams so a re-entry tick is treated as first contact and snaps precisely.Out of scope
The 1-frame upside-down flicker on pill change in the editor compositor remains. It's a Chrome
copyExternalImageToTexture(<video>)codec-orientation hiccup, not addressable without a structural rewrite of the preview render pipeline (e.g. WebCodecsVideoDecoder+VideoFrame).Test plan
🤖 Generated with Claude Code