Skip to content

fix(playback): backward seek freeze from epoch/monotonic clock mismatch - #350

Merged
theunavailableguy merged 1 commit into
masterfrom
fix/backward-seek-preview-freeze
Sep 21, 2026
Merged

theunavailableguy merged 1 commit into
masterfrom
fix/backward-seek-preview-freeze

Conversation

@AIEraDev

Copy link
Copy Markdown
Owner

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.

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
theunavailableguy merged commit fe493e9 into master Sep 21, 2026
2 checks passed
@theunavailableguy
theunavailableguy deleted the fix/backward-seek-preview-freeze branch September 21, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants