Prevent matterjs stalls when returning to inactive tabs #6978
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please do not update the README or Change Log, we will do this when we merge your PR.
This PR (delete as applicable)
Describe the changes below:
Fixes #6977
A more complete PR would include adding this to the type
Phaser.Types.Physics.Matter.MatterRunnerConfig
This change limits the amount of time matterjs will be simulating after a tab is inactive for a long time. The number 100ms seems a reasonable maximum amount of time to wait for the game loop to resume.
Another issue with this PR is I don't understand why does src/physics/matter-js/World.js not use
Runner.create
as defined in src/physics/matter-js/lib/core/Runner.js but I'd rather someone that knows what's going on give an opinion on that.