Skip to content

TweenBuilder crashes when targets contain null/undefined or destroyed objects #7215

@aomsir

Description

@aomsir

Description

Creating a tween with targets that include null, undefined, or
destroyed game objects will cause a runtime error in TweenBuilder.

This happens because the scale shortcut logic calls:

target.hasOwnProperty('scale')

without checking whether target is valid.

Reproduction

var sprite = this.add.sprite(400, 300, 'logo');
sprite.destroy();

this.tweens.add({
    targets: [sprite, null, undefined],
    x: 500,
    duration: 1000
});

Error:

TypeError: Cannot read properties of null (reading 'hasOwnProperty')

Expected behavior

Invalid targets should be skipped instead of causing a crash.

Affected versions

Phaser 3.53.1 → 3.90.0

Related PR

Fix PR: #7211

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