I basically have a lerp function similar to this one: Client interpolation for 100% serverside game when a new server update is received, the update frequency is added to a variable (msAhead) and the delta is subtracted from it every client frame. But when I do it the variable msAhead increases a lot when the tab is switches from inactive to active. Here is my code:
msAhead += updateFrequency; //when new update is received. (function loop(now) { var now = Date.now(); delta = now - Time; Time = now; msAhead -= delta; console.log(msAhead); requestAnimationFrame(loop) })(0); How can I fix my issue?