Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

ja-ni
Copy link
Contributor

@ja-ni ja-ni commented Apr 8, 2024

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 ja-ni added the bug Something isn't working label Apr 8, 2024
@ja-ni ja-ni self-assigned this Apr 8, 2024
@ja-ni ja-ni changed the title Ore UI back button appears blurry, and the size of the button doesn’t match the Json UI counterpart Shared facets are still subscribed to after leaving screens Apr 8, 2024
@ja-ni ja-ni requested a review from Shenato April 8, 2024 13:16
@ja-ni ja-ni marked this pull request as ready for review April 8, 2024 13:37
@pirelenito pirelenito changed the title Shared facets are still subscribed to after leaving screens Fix memory leak within the @react-facet/dom-fiber Apr 10, 2024
@pirelenito pirelenito marked this pull request as draft April 10, 2024 12:13
@ja-ni ja-ni marked this pull request as ready for review April 24, 2024 13:35
@ja-ni
Copy link
Contributor Author

ja-ni commented Apr 24, 2024

Tests to be produced within the as a Test screen

marlonicus and others added 7 commits April 30, 2024 11:47
…fter-leaving-screens' of github.com:Mojang/ore-ui into core-ui/1166334-shared-facets-are-still-subscribed-to-after-leaving-screens
…fter-leaving-screens' of github.com:Mojang/ore-ui into core-ui/1166334-shared-facets-are-still-subscribed-to-after-leaving-screens
@ja-ni ja-ni merged commit 9b98b4f into main May 16, 2024
12 checks passed
@ja-ni ja-ni deleted the core-ui/1166334-shared-facets-are-still-subscribed-to-after-leaving-screens branch May 16, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants