fix(playback): backward seek freeze from epoch/monotonic clock mismatch - #350
Merged
Merged
Conversation
Root cause: _seekStartedAtMs was recorded with performance.now() but the
timeout check in _tick() compared against Date.now() (Unix epoch). The
delta was always ~1.77 trillion ms, causing completeSeek() to fire on the
very first tick after any seek — clearing _isSeeking before the seek
settled.
PlaybackClock.ts setNativeClockPosition() guards stale backward audio
samples with:
return // discard stale sample
With _isSeeking forced false immediately, every backward audio sample was
discarded as 'stale'. Forward seeks were unaffected because clampedTime >
_time always passes the guard.
PlaybackClock.ts:
- Switch _tick() seek timeout check from Date.now() to performance.now()
so elapsed time is measured in the same monotonic domain as _seekStartedAtMs
- Reset _nativeClockPosition = null on paused seeks so stale native samples
do not pollute the new seek position
- Align _nativeClockPosition to this._time immediately on seek-- Align _nativeClockPosition to this._time immediately on seek-- Ali the - Align _nativeClockPosition to this._time immediately on seek-- Aligoo- Align _nativeClockPosition to this._time immediately on seek-- Align _ s- Align _nativeClockPosition to this._time immediately on seek-- Aligme; previously forceRenderNeeded was set but the
RAF loop was not woken, causing settling fram RAF loop was not woken, causing settling fram RAF loop was not woken, ca10 files);
preview suite 188/188 (16 files)
theunavailableguy
approved these changes
Sep 21, 2026
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 backward seeks not updating the program preview, introduced by the BUG-5 seek timeout check.
Root cause: _seekStartedAtMs was recorded with performance.now() but _tick() checked Date.now(). The ~1.77 trillion ms delta caused completeSeek() to fire on the first tick, clearing _isSeeking immediately. setNativeClockPosition() then discarded every backward audio sample as stale. Forward seeks were unaffected.
PlaybackClock.ts: Date.now() -> performance.now() in timeout check; reset _nativeClockPosition on paused seeks; align _nativeClockPosition to this._time on seek-while-playing.
NativeProgramPreview.tsx: Add wakeNativeRenderLoopRef.current?.() in seekController.subscribe() when isSettling so the RAF loop is actually woken for settling frames.
Verified: tsc clean; playback 72/72; preview 188/188.