You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding a GameObject to a Layer throws unhandled exceptions when the Scene they're added to shuts down (such as when transitioning to a new scene).
The Scene destroys the Layer, then the Layer destroys the Sprite which causes it to emit its DESTROY event. This event is caught by the Layer which removes the Sprite from its list as well as attempts to destroy it again because the Layer is being destroyed by the scene. The destroy attempted by the Layer throws an exception in Sprite.preDestroy when this.anims is null because it was already removed by the original destroy.
The demo attempts to add a Sprite to a Layer, then transition to a different Scene which displays a small green square. Currently, the demo crashes while trying to stop the current scene. The demo completes successfully if the line adding SceneA's rect to the layer is removed, or if the Phaser dependency is set to a version before 3.70.0.
Additional Information
The exception thrown by the demo doesn't trace the source of the issue well, I've attached an image of a call stack from a debugger as well.
The text was updated successfully, but these errors were encountered:
I'm having the same issue. But for me it only happens when I restart the scene (this.scene.restart()). If I switch to a new scene this is not a problem.
Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.
Version
Description
Adding a GameObject to a Layer throws unhandled exceptions when the Scene they're added to shuts down (such as when transitioning to a new scene).
The Scene destroys the Layer, then the Layer destroys the Sprite which causes it to emit its DESTROY event. This event is caught by the Layer which removes the Sprite from its list as well as attempts to destroy it again because the Layer is being destroyed by the scene. The destroy attempted by the Layer throws an exception in Sprite.preDestroy when this.anims is null because it was already removed by the original destroy.
Example Test Code
https://codepen.io/crockergd/pen/RwvMxNG
The demo attempts to add a Sprite to a Layer, then transition to a different Scene which displays a small green square. Currently, the demo crashes while trying to stop the current scene. The demo completes successfully if the line adding SceneA's rect to the layer is removed, or if the Phaser dependency is set to a version before 3.70.0.
Additional Information
The exception thrown by the demo doesn't trace the source of the issue well, I've attached an image of a call stack from a debugger as well.
The text was updated successfully, but these errors were encountered: