Mojang / ore-ui

💎 Building blocks to construct game UIs using web tech.
https://react-facet.mojang.com/
MIT License
404 stars 19 forks source link

Fix memory leak within the @react-facet/dom-fiber #136

Closed ja-ni closed 4 months ago

ja-ni commented 5 months ago

As the renderer handles subscriptions, its important that whenever a Facet data is no longer needed, the renderer should make sure that the cleanup is called.

We have identified two scenarios where the custom React renderer wouldn't correctly unsubscribe from a Facet.

Untracked properties

Some properties that were introduced recently to support SVG didn't had their subscription cleanup correctly called when React components were unmounted.

Appending nodes in specific index positions

On most scenarios, nodes are simply "appended to a child", and for those, the prior implementation was correctly tracking parent-child relationships so that cleanup was handled correctly.

However, the prior implementation would also assume incorrectly that both insertBefore and insertInContainerBefore would be called after a appendChild, so relationship tracking was not being done correctly and we had some child nodes that were never being cleaned-up.

ja-ni commented 4 months ago

Tests to be produced within the as a Test screen