Skip to content

Detach element component graph nodes on destroy - #9183

Merged
mvaligursky merged 1 commit into
mainfrom
mv-element-node-leak
Aug 17, 2026
Merged

Detach element component graph nodes on destroy#9183
mvaligursky merged 1 commit into
mainfrom
mv-element-node-leak

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

The image and text element internals parent a GraphNode to their entity, but neither detached it on destroy. The node therefore stayed in entity.children for the lifetime of the entity - so removeComponent('element') left one behind, and every element.type change added another. This is the accumulating half of #4333.

Changes:

  • ImageRenderable#destroy and TextElement#destroy now detach their graph node from the entity, matching what SpriteComponent already does.
  • Added element component tests covering type changes and component removal, for both the image and text types.

The image and text element internals parent a GraphNode to their entity,
but neither detached it on destroy, so it stayed in entity.children for
the lifetime of the entity.
@github-actions

Copy link
Copy Markdown

Build size report

This PR changes the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2366.5 KB (+0.1 KB, +0.00%) 607.7 KB (+0.0 KB, +0.00%) 471.8 KB (−0.3 KB, −0.06%)
playcanvas.min.mjs 2363.9 KB (+0.1 KB, +0.00%) 606.7 KB (+0.0 KB, +0.00%) 471.5 KB (+0.2 KB, +0.05%)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Detaches internal element graph nodes during destruction to prevent stale children from accumulating.

Changes:

  • Detach image and text graph nodes on destroy.
  • Add regression tests for type changes and component removal.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/framework/components/element/image-element.js Detaches the image render node during cleanup.
src/framework/components/element/text-element.js Detaches the text render node during cleanup.
test/framework/components/element/component.test.mjs Tests node cleanup across type changes and removal.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mvaligursky
mvaligursky merged commit aae49be into main Aug 17, 2026
11 checks passed
@mvaligursky
mvaligursky deleted the mv-element-node-leak branch August 17, 2026 11:49
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

Successfully merging this pull request may close these issues.

2 participants