Delta time returning large numbers when regaining window focus

Hi guys,

I noticed that in the latest version of the engine, dt is no longer clamped (inside the makeTick function) and this seems to be causing various elements of our project to speed up extremely for a number of seconds (relative to the time spent in a different tab. For example our tweens and p2 physics implementation in particular seem to be noticeably sped up for a number of seconds before they settle down again.

Wondering if the removal of the dt clamp was intentional and I need to override makeTick myself?


Let’s take the p2.js integration project:

Now it behaves exactly like the official p2.js examples when switching tabs:

Previously, clamping the dt arbitrarily to 0.1 was just wrong. It made performance testing pretty much impossible because you could never register less than 10fps. I’m open to suggestions here.

I’m wondering if this should be fixed in the scripts themselves rather than in the application’s tick function. It’s pretty easy to clamp dt in the p2.js integration script (and the tween script too).

1 Like

Should we maybe set the last update time to now when the user returns to the tab? That way dt will be 0 the first frame you return to the tab.

1 Like

If we can make that work, I’d be happy with that.

Hello guys,

we are still receiving high deltaTime value when regaining focus which cause a lot of animation and character navigation bug. Should we override makeTick with a clamp?

7.682700000004843 <----- DeltaTime when regaining focus


Hey David,

We ended up overriding MakeTick and clamping to fix this issue

1 Like

Ok, we will do the same, Thank you!

Recently I’ve seen a commit on this subject:

Wasn’t enough to fix it?

1 Like

I have missed that commit when I checked them. The playcanvas lib in my local setup is 2 weeks old. That is my mistake. Logically it will fix the issue. I’ll update my local setup and revert my fix. Thanks

1 Like