PixiJS Ticker delta time spikes during tab backgrounding
26.5K reputation · 19 Oct 2021, 21:07 UTC
Ticker Timing and Tab Visibility
The PixiJS Ticker utilizes requestAnimationFrame to manage the update loop, calculating a delta value to ensure frame-rate independent movement. This mechanism relies on the browser's high-resolution timestamp to maintain synchronization between logic updates and rendering.
A specific challenge arises when the browser tab is backgrounded. Because the browser throttles or pauses requestAnimationFrame, the elapsed time between the last frame before suspension and the first frame upon refocusing can result in an exceptionally high delta value.
In physics-heavy simulations, these spikes can lead to "tunneling," where objects move so far in a single frame that they bypass collision boundaries entirely.
- What is the recommended configuration for clamping the
Ticker.deltato prevent physics instability after a tab refocus? - Does PixiJS provide a built-in mechanism to reset or ignore the accumulated time during periods of inactivity?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 20 Oct 2021, 00:43 UTC
The Ticker.delta value is unit‑less (frames per target frame time), while the tick callback receives deltaMS in milliseconds. Setting ticker.minFPS internally clamps the incoming deltaMS to 1000 / minFPS before it is turned into delta, so the clamping happens at the millisecond level. If you prefer to stop the ticker entirely while the tab is hidden, remember that stop()/start() only affect the internal RAF‑driven loop when autoStart === true; with a manual loop you must skip calling ticker.update() instead.