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

2d CameraManager do not unregister RESIZE event when be destroyed #5791

Closed
liuhongxuan23 opened this issue Jul 25, 2021 · 1 comment
Closed

Comments

@liuhongxuan23
Copy link

liuhongxuan23 commented Jul 25, 2021

Version

  • Phaser Version: v3.55.2

Description

https://github.com/photonstorm/phaser/blob/5c8ecbcf999e6f328d21884e877c9e5935d2d350/src/cameras/2d/CameraManager.js

The event is registered at line 163, but will never be unregistered. This will introduce garbage objects if we continuously create and destroy scenes.

sys.game.scale.on(ScaleEvents.RESIZE, this.onResize, this);

Example Test Code

var game = new Phaser.Game({});

game.scene.add("dummy", {}, true);
setInterval(function () {
    game.scene.remove("dummy");
    game.scene.add("dummy", {}, true);
    console.log(game.scale.listenerCount("resize"));
} ,1000);
@photonstorm
Copy link
Collaborator

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.

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

2 participants