From a858de9bd43411d90b0c2bc44445357a36e264a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 3 Jun 2026 01:13:26 +0000 Subject: [PATCH] fix(runtime): make audio/media sync boundary inclusive to match visibility fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `init.ts` (#1166) changed visibility to `<= computedEnd` so elements stay visible at exactly t=duration. Audio clock (`init.ts:1908`) and `syncRuntimeMedia` (`media.ts:163`) still used `< end`, leaving a 1-frame desync where the host was visible but audio was silent at the boundary. Change both to `<=` for symmetry: - At clip end (seeking to t=duration): audio plays through the final frame - At adjacent boundaries: the `break` in syncRuntimeMedia ensures only the outgoing clip's audio is attached — no simultaneous dual activation Co-Authored-By: Claude Sonnet 4.6 --- packages/core/src/runtime/init.ts | 2 +- packages/core/src/runtime/media.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/runtime/init.ts b/packages/core/src/runtime/init.ts index 2a9200e24..6b62d3cfb 100644 --- a/packages/core/src/runtime/init.ts +++ b/packages/core/src/runtime/init.ts @@ -1933,7 +1933,7 @@ export function initSandboxRuntimeModular(): void { const mediaStart = Number.parseFloat(rawEl.dataset.playbackStart ?? rawEl.dataset.mediaStart ?? "0") || 0; - if (Number.isFinite(start) && state.currentTime >= start && state.currentTime < end) { + if (Number.isFinite(start) && state.currentTime >= start && state.currentTime <= end) { if (!rawEl.paused) { clock.attachAudioSource({ el: rawEl, compositionStart: start, mediaStart }); foundActive = true; diff --git a/packages/core/src/runtime/media.ts b/packages/core/src/runtime/media.ts index 55658554b..0e65c28eb 100644 --- a/packages/core/src/runtime/media.ts +++ b/packages/core/src/runtime/media.ts @@ -165,7 +165,7 @@ export function syncRuntimeMedia(params: { // (el.ended resets to false when the user scrubs back, so seeks work.) const isActive = params.timeSeconds >= clip.start && - params.timeSeconds < clip.end && + params.timeSeconds <= clip.end && relTime >= 0 && (!el.ended || clip.loop); if (isActive) {