Skip to content

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

@liuhongxuan23

Description

@liuhongxuan23

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions