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.
This commit is contained in:
Miguel Ángel
2026-05-13 15:29:36 -07:00
parent c0c3b8dea9
commit c7eefdfa1a
@@ -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;