You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ecs): stop a re-arming setTimeout from hanging the scene on a large dt (#1420)
* fix(ecs): stop a re-arming setTimeout from hanging the scene on a large dt
A timer callback that schedules a new timer mutates the Map the timer
system is iterating, and for..of visits entries inserted mid-iteration.
Since the loop also applies the frame's full 1000 * dt to those new
timers, any interval <= 1000 * dt fires immediately within the same pass,
so a self-re-arming setTimeout loops forever once dt exceeds its interval
and the scene worker never returns.
Seed timers armed inside a firing callback with the negative of the time
already consumed this frame before the parent fired, so the loop's
+= elapsedMs nets to the true elapsed time. Re-arming chains then stay
phase-accurate (matching setInterval) and catch up a bounded number of
times instead of looping. Top-level timers, including setTimeout(cb, 0),
are unchanged.
* test: update snapshots for timer re-arm fix
0 commit comments