Deterministic Lockstep: Physics simulation paused while window inactive or in background

Hope you are all staying healthy and happy :slight_smile:

Just had a question about Deterministic Lockstep:

I added a console log to the example in Advanced Animation Methods | Babylon.js Documentation. Please find the slightly modified PG here:

If I run the PG normally, the simulation takes ~9 seconds and the console logs:
duration: 9.204

However, if I run the PG, background it by switching to a different tab or application window, and return to the PG several seconds later, the simulation takes much longer than 9 seconds (9 seconds + amount of time the PG was backgrounded)

I may be misunderstanding Deterministic Lockstep, but I thought that the physics simulation should take the same amount of time in seconds. Would anyone know how to work around the backgrounding of the PG?

Thank you all for your help!

unfortunately we rely on the RequestAnimationFrame which is stop in some browser while in background to save battery and perf.

The only way to continue compute in background would be when the tab goes away, start a setInterval on 16 ms and run the code of your render loop in.


Ah thanks, sebavan!