-
Notifications
You must be signed in to change notification settings - Fork 491
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
RenderTexture can crash if games are created and destroyed in quick succession. #729
Comments
I think I have a branch for this. |
Fixed in dde4ef2 |
Thanks! 🙇 |
Hi @samme thanks again for the fix for this issue. Do you have any plans to release it in the near future? It's still affecting us so we may need to consider a fork, or depending directly on this Github repo, in the meantime. |
I'll make a release soon. |
Thanks @samme 🙇 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Issue is about
RenderTexture
Uncaught TypeError: Cannot read properties of null (reading 'type')
Crash occurs at https://github.com/photonstorm/phaser-ce/blob/1af938320a72ebc0cfbd9cc9101fcf1bf17d9808/src/gameobjects/RenderTexture.js#L86
Background
We're using a NextJS/React client to run some Phaser games. We're using React's effects inside functional components, since the rendering of a Phaser game is considered a side effect outside of React's control. In development, React has a Strict Mode that will cause these effects to double-render these functional components, in order to help devs identify unintentional side effects in their code
This means our Phaser games are being created, very quickly destroyed, then created again. Some of our games use
RenderTexture
, which isn't resilient to these quick create/destroy/create cycles.The issue appears to stem from
RenderTexture
's reliance on global state; specifically,PIXI.defaultRenderer
.https://github.com/photonstorm/phaser-ce/blob/1af938320a72ebc0cfbd9cc9101fcf1bf17d9808/src/core/Game.js#L1279
I think what's happening is
Phaser.Game#destroy
will setPIXI.defaultRenderer
tonull
, which causes a race condition where the 2nd game'srenderer
may or may not benull
.I am happy to contribute a PR, once folks have a chance to triage and comment on the issue.
The text was updated successfully, but these errors were encountered: