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

Allow overriding contextRestoredHandler in WebGLRenderer so we can control when a restore is called #6796

Open
yaustar opened this issue Apr 18, 2024 · 0 comments

Comments

@yaustar
Copy link

yaustar commented Apr 18, 2024

At the moment, context restore in Phaser happens when the browser signals it has been restored. We would like to control when this happens so that we can try to increase the chances that the context stays restored.

For example, we see that context losses mostly happen when the tab is in background and for some situations, it would restore only to immediately lose it again.

We would like to try to restore the Phaser WebGLRenderer when the tab is next active instead so it only happens once and perhaps the browser will prioritise resources to it now that it is focused.

The side effect is that errors can be thrown from Phaser during the restore process that we would like to try/catch and track for analytics and that's not possible with the current restore process.

As a potential PR, I was thinking about wrapping the webglcontextrestored and webglcontextlost event listeners in private functions that internally call contextRestoredHandler / contextLostHandler instead of it being the listener directly. Maybe even separate the renderer restore logic into a separate function so that it could be called by custom overrides.

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

No branches or pull requests

1 participant