From 0b41180297a4e49104628e958de35031546c6d86 Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Mon, 9 Nov 2026 03:43:58 -0500 Subject: [PATCH] perf(core): Safari plays a long source's audio from its element, not a whole-file decode --- 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 d4e1e21eca..2ab19b1978 100644 --- a/packages/core/src/runtime/init.ts +++ b/packages/core/src/runtime/init.ts @@ -517,12 +517,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