From 53189a3cf8921ea0954578246d544d7a2fb77c5c Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Mon, 9 Nov 2026 05:08:39 -0500 Subject: [PATCH] perf(core): Safari defers later clips and plays a long source's audio from its element --- packages/core/src/runtime/init.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/runtime/init.ts b/packages/core/src/runtime/init.ts index bd0f275ee7..5c368496d9 100644 --- a/packages/core/src/runtime/init.ts +++ b/packages/core/src/runtime/init.ts @@ -518,12 +518,16 @@ const joinsWebAudio = (el: Element): el is HTMLMediaElement => })); const WEB_AUDIO_MEDIA = "audio[data-start], video[data-start]"; +const DECODE_FIRST_MAX_SECONDS = 120; + /** WebKit restarts a media element's audio 150 to 400 ms late; a decoded buffer on the context clock starts on time. */ function decodesFirst(el: HTMLMediaElement, webAudio: WebAudioTransport): boolean { return ( isWebKit() && isAudioElement(el) && !el.loop && + // A long source's whole-file fetch takes the link from the picture; its audio plays from the element. + el.duration <= DECODE_FIRST_MAX_SECONDS && webAudio.fitsDecodeBudget(el) && typeof readElementRateSpec(el) === "number" && readElementPlaybackRate(el) === 1