fix(runtime): make audio/media sync boundary inclusive to match visibility fix (#1173)

`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 <noreply@anthropic.com>
This commit is contained in:
Miguel Ángel
2026-06-05 16:38:34 -04:00
committed by GitHub
co-authored by Claude Sonnet 4.6
parent 6bd1e764e5
commit b6a14ea9f5
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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) {