Hybrid timeline sync: an Animation timeline-locks the video preview (source-media issue 05) - #16
Merged
Conversation
…source-media issue 05) With an Animation the preview <video> stays paused and a transient playhead subscription seeks it (playheadT % videoDuration, core's videoTimeAtPlayhead), so scrubbing and timeline play drive video and animation in lockstep; without one the free-run rVFC path is unchanged. The rVFC invalidate now runs in both modes because VideoTexture uploads on its own rVFC, after `seeked`. The free-run play/pause chip hides while the timeline owns playback.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
<video>element stays paused and a transient playhead subscription seekscurrentTime = playheadT % videoDuration, so scrubbing the timeline scrubs the video and timeline play advances both in lockstep. Without an Animation the free-run path (autoplay/loop/rVFC, issue 04) is untouched; adding or removing an Animation switches modes.core/media-time.ts(videoTimeAtPlayhead), written test-first: wrap at the intrinsic duration, whole-loop landings, negative playheads, and zero/NaN/Infinityduration guards.invalidate()loop now runs in both modes:VideoTextureflags its GPU upload from its own internal rVFC, which lands after theseekedevent, so aseeked-driven repaint painted the stale frame (found during evidence capture). rVFC goes silent when nothing presents, so zero-frames-idle holds in both modes.Mechanism per the ticket, settled by the
proto/video-preview-playbackprototype.Evidence
Playwright + instrumented GL draw-call counter, in
.scratch/source-media/evidence/05/(script:.scratch/pw-runner/capture-hybrid-sync-evidence.cjs, frame-counter clip):Test plan
pnpm typecheck,pnpm lint,pnpm build,pnpm test(443 tests, 26 files) greenNote
Medium Risk
Touches preview rendering and playhead/video sync paths; behavior is well-tested in core but browser seek/rVFC timing remains inherently fragile.
Overview
When the document has an Animation, source video preview switches from free-run playback to timeline-locked mode: the
<video>stays paused and seeks tovideoTimeAtPlayhead(playheadT, duration)on playhead changes, so scrubbing and timeline transport stay in sync. Without an Animation, the existing free-run path (store play/pause + rVFC) is unchanged; mode flips when an Animation is added or removed.videoTimeAtPlayheadincore/media-time.tscentralizes wrap-at-duration and guards for invalid duration/playhead; it is exported from core and covered by unit tests.useSourceVideoTexturesplits effects: free-run still subscribes tovideoPreviewPlaying; timeline-locked subscribes toplayheadTwith a micro-seek epsilon to avoid decoder churn. rVFC →invalidate()now runs in both modes so locked seeks show the presented frame (not stale texture afterseekedalone). The dropzone play/pause chip hides while timeline-locked so it does not fight timeline transport.Reviewed by Cursor Bugbot for commit 11c4551. Bugbot is set up for automated code reviews on this repo. Configure here.