playcanvas / playcanvas/engine

Disabling a child in a script while its parent is being disabled is broken

Open
#747 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

This is the current enabled property setter on an Entity:

if (this._enabled !== enabled) {
  this._enabled = enabled;

  if (! this._parent || this._parent.enabled)
    this._notifyHierarchyStateChanged(this, enabled);
}

When _notifyHierarchyStateChanged is called it will fire the disable event handler on scripts. If a script tries to disable a child Entity during this event, then the children of that Entity will not be disabled because this._parent._enabled is false. But the parent has not finished disabling itself yet.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Entity enabled property setter and _notifyHierarchyStateChanged, then reproduce a parent-disable event whose script disables a child. Trace the hierarchy state propagation and verify that the child and its descendants are disabled before considering the issue resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.