Skip to content

Containers' children not removed from (in fact added to) updateList when destroyed #5818

@prakol16

Description

@prakol16

Version

  • Phaser Version: 3.55.2
  • Operating system: Ubuntu
  • Browser: any

Description

The issue is that during the removeHandler, an exclusive container adds the gameobject (which uses preUpdate, say a sprite) back to the display list, causing it to be added to the update list; then the destroy finishes, and it is removed from the update list. But the update list does not process additions and deletions immediately; instead, it now has the object in both _pending and _destroy. The end result of this is that it ends up being added to the update list, even if it wasn't originally, when the object is destroyed from within a container.

Example Test Code

I'm using the same code as the previous issue (#5817) for convenience: https://codepen.io/prakol16/pen/YzQXxpg. Note that there, because of the bug, the sprite is never added to the update list while it is alive. However, as soon as it is destroyed, it is added to the update list because of this bug, even though it wasn't on the updateList to begin with. Note that V3 in that issue, which causes the sprite to be added to the update list, is caused by the exact same issue as this bug (adding to both _pending and _destroy). It's just that there, we wanted the sprite to be in the update list, so this bug masks that bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions