Skip to content

fix(core): Safari audio is ready at the cut, and a stuck one resyncs in 1 s - #7024

Merged
miguel-heygen merged 3 commits into
mainfrom
fix/safari-latecut
Nov 2, 2026
Merged

miguel-heygen merged 3 commits into
mainfrom
fix/safari-latecut

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What

In Safari, the sound at a clip change can start late. Two causes, both fixed in the one place media sync routes through:

  • The incoming audio element is still seeking to its in-point when the cut arrives. WebKit audio is now seeked to its in-point ahead of the cut, the way upcoming video already is.
  • An audio element frozen on its seek is waited on for 3 s before the sync valve pulls it onto the playhead. In WebKit that valve is now 1 s for audio.

Chromium and Firefox are unchanged (both changes are gated on WebKit).

Why

Late cuts of 600 ms or more happened at about 1 in 7 clip changes on an iPhone; the 3 s ones were the valve waiting on a frozen element.

Related work

Follows the iPhone connection work in #7012 (merged).

How

What goes wrong: a clip's audio element is only told to seek when the cut arrives, and WebKit takes long enough to land that seek that the sound starts late; a WebKit element stuck on its seek is then waited on for 3 s.

The runtime already pre-seeked upcoming video (media.ts prepareUpcomingMedia); this extends that to WebKit audio (preloadMedia.ts:39) and shortens the frozen-audio valve to 1 s (media.ts:649).

Test plan

Fails without the fix: with media.ts and preloadMedia.ts restored to main, exactly the two new tests fail (2 failed, 204 passed); with the fix 206 passed (devbox, head b7f3491).

  • Unit tests added: WebKit audio pre-seeks its in-point (preloadMedia.test.ts); a frozen WebKit audio element is pulled onto the playhead after 1 s, not 3 (media.test.ts)
  • Core runtime suite on the devbox at c6ddf2d: 112 files, 2727 tests passed (b7f3491 only shortens a comment)
  • Device: the only device number is last night's partial run: late cuts went from 11 of 90 to 7 of 90 with the audio preparation. The valve change was not measured. Not measured on a real iPhone after this change.
  • Comments follow CONTRIBUTING.md

Size

A lone 46-line fix: two WebKit-gated conditions in the single media sync path plus their tests; nothing else open can carry it.

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve at a3a403d0 (re-pinned from b7f34910; that commit only drops the comment above WEBKIT_STUCK_AUDIO_SECONDS).

  • Fails without the fix: confirmed. With media.ts and preloadMedia.ts from main, the two new tests fail (2 failed, 204 passed). At head: 206 passed.
  • Both changes check isWebKit(). The preload path now pre-seeks WebKit audio on loadedmetadata, the same way upcoming video already gets pre-seeked, and the isUpcoming / paused / seeking guards still apply.
  • Non-blocking: the tier-1 comment in syncRuntimeMedia still says "catastrophic drift (>3s)". It's 1 s for WebKit audio now. Also, on a slow link, cold WebKit audio may now get re-seeked about every 1 s while it buffers instead of every 3 s. That's acceptable since Remotion re-seeks at 0.65 s, but it's worth watching in the device run that hasn't been done yet.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 108 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (1)

  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 2, 2026
@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit c25e092 Nov 2, 2026
141 of 145 checks passed
@miguel-heygen
miguel-heygen deleted the fix/safari-latecut branch November 2, 2026 17:04
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.

1 participant