PixiJS Ticker delta time spikes during tab backgrounding
19K 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?