From c7eefdfa1ac9c5a967783e14a1f788680a6f8446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 13 May 2026 15:29:36 -0700 Subject: [PATCH] fix(studio): guard against inverted in/out work-area points in loop ticks If the user sets out-point before in-point (outPoint < inPoint), rawLoopStart >= rawLoopEnd caused the loop guard to fire immediately on every tick, creating a tight infinite seek loop. Both the forward RAF tick and the reverse RAF tick now fall back to the full composition range when the work area is invalid. --- .../studio/src/player/hooks/useTimelinePlayer.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/studio/src/player/hooks/useTimelinePlayer.ts b/packages/studio/src/player/hooks/useTimelinePlayer.ts index 1d46e4302c..93e1c46fbc 100644 --- a/packages/studio/src/player/hooks/useTimelinePlayer.ts +++ b/packages/studio/src/player/hooks/useTimelinePlayer.ts @@ -186,8 +186,10 @@ export function useTimelinePlayer() { const dur = adapter.getDuration(); liveTime.notify(time); // direct DOM updates, no React re-render const { inPoint, outPoint } = usePlayerStore.getState(); - const loopEnd = outPoint !== null ? outPoint : dur; - const loopStart = inPoint !== null ? inPoint : 0; + const rawLoopEnd = outPoint !== null ? outPoint : dur; + const rawLoopStart = inPoint !== null ? inPoint : 0; + const loopEnd = rawLoopStart < rawLoopEnd ? rawLoopEnd : dur; + const loopStart = rawLoopStart < rawLoopEnd ? rawLoopStart : 0; if (time >= loopEnd && !adapter.isPlaying()) { if (usePlayerStore.getState().loopEnabled && dur > 0) { adapter.seek(loopStart); @@ -273,8 +275,10 @@ export function useTimelinePlayer() { const elapsed = ((now - startedAt) / 1000) * speed; let nextTime = startTime - elapsed; const { inPoint, outPoint } = usePlayerStore.getState(); - const loopEnd = outPoint !== null ? outPoint : duration; - const loopStart = inPoint !== null ? inPoint : 0; + const rawLoopEnd = outPoint !== null ? outPoint : duration; + const rawLoopStart = inPoint !== null ? inPoint : 0; + const loopEnd = rawLoopStart < rawLoopEnd ? rawLoopEnd : duration; + const loopStart = rawLoopStart < rawLoopEnd ? rawLoopStart : 0; if (nextTime <= loopStart) { if (usePlayerStore.getState().loopEnabled && duration > 0) { startTime = loopEnd;