Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative delta time #3088

Closed
Antriel opened this issue Nov 9, 2017 · 0 comments
Closed

Negative delta time #3088

Antriel opened this issue Nov 9, 2017 · 0 comments

Comments

@Antriel
Copy link
Contributor

Antriel commented Nov 9, 2017

Using latest Phaser build.
This issue only happens in chrome as far as I can tell, and isn't deterministic.
Stripped down example:

var before = performance.now();
requestAnimationFrame(function frame(now) {
  console.log(now - before);
});

This will log negative value for me with chrome 61.0.3163.100 (64-bit).

Given that Phaser uses performance.now() in TimeStep.resetDelta, and then uses value from RAF, the result is negative delta time being passed down to update. Given how smoothing works it will stay negative for up to 10 frames.

One solution would be to check for negative rawDelta in TimeStep.step. Another, would be to have TimeStep.resetDelta not perform the actual reset, rather rebind RAF callback to reset method (which would then bind it back to normal step).

Or consider it a chrome bug and not fix it at all, leaving developers to handle this. Admittedly, in usual usage, the first 10 frames of the game aren't critical.

Seems like I'm not the only one with this issue: https://stackoverflow.com/a/46121920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants