Skip to content

fix: video drive the timeline#640

Open
stefpi wants to merge 21 commits into
masterfrom
ios-video-sync
Open

fix: video drive the timeline#640
stefpi wants to merge 21 commits into
masterfrom
ios-video-sync

Conversation

@stefpi

@stefpi stefpi commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

No description provided.

sshane and others added 7 commits April 30, 2026 05:48
The video player was kept in sync with a virtual timeline clock by
nudging videoElement.playbackRate by ±0.1 every 200-500ms whenever
they drifted. Each playbackRate write hits the audio decoder, so on
audio-sensitive paths (iOS Safari, CarPlay, AirPlay/Bluetooth, macOS
audio routes) the audio crackled, stuttered, and dropped.

Several layers of workarounds had grown around it:

- iOS hid the playback speed UI entirely.
- iOS skipped the rate-fudge step (so iOS audio was OK, but iOS video
  drifted from the timeline and `readyState` got pumped via a
  force-pause hack to "unstick" the buffer).
- Firefox capped at 8x because it mutes audio above 8x.
- HLS.js had a custom pause/play orchestration to work around the
  rate writes interfering with playback.

This change inverts the model: the video plays at its declared rate
and the timeline follows it, instead of the timeline driving the
video. syncVideo now only acts on real divergence:

- |diff| > 0.5s → push to video (user seek, loop wrap, initial sync).
- |diff| > 0.05s while playing → pull the timeline to the video by
  dispatching a seek action (Redux only, no media-element touch).

Buffering state switches to the browser's own waiting/playing events
via ReactPlayer's onBuffer/onBufferEnd, replacing the readyState
polling and the iOS-specific force-pause "fix". Drops the 16x cap and
the Firefox 8x branch — playback rate is now whatever the user
actually selected, not a moving target.

Restores the speed UI on iOS, drops the now-unused isFirefox helper.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stefpi stefpi marked this pull request as draft June 23, 2026 22:14
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Welcome to connect! Make sure to:

  • read the contributing guidelines
  • mark your PR as a draft until it's ready to review
  • post the preview on Discord; feedback from users will speedup the PR review

deployed preview: https://640.connect-d5y.pages.dev

@stefpi stefpi marked this pull request as ready for review July 7, 2026 04:35
@stefpi stefpi linked an issue Jul 7, 2026 that may be closed by this pull request
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.

Fix iOS video playback issues by syncing audio to video

2 participants