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(core): remove nested views from registry when root is destroyed #41894

Closed
wants to merge 1 commit into from

Conversation

crisbeto
Copy link
Member

This is a follow-up to #41358 where my assumption was that destroyLView would be called for all views down the tree, but it turns out that it only gets called for the root and we actually call cleanUpView for the descendants. The result is that some views might not be removed from the registry after they're destroyed.

These changes move the unregisterLView call into cleanUpView instead.

This is a follow-up to angular#41358 where my assumption was that `destroyLView` would be called for all views down the tree, but it turns out that it only gets called for the root and we actually call `cleanUpView` for the descendants. The result is that some views might not be removed from the registry after they're destroyed.

These changes move the `unregisterLView` call into `cleanUpView` instead.
@google-cla google-cla bot added the cla: yes label Apr 30, 2021
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: rc This PR is targeted for the next release-candidate labels Apr 30, 2021
@ngbot ngbot bot added this to the Backlog milestone Apr 30, 2021
@crisbeto crisbeto marked this pull request as ready for review April 30, 2021 09:05
@ngbot ngbot bot modified the milestone: Backlog Apr 30, 2021
@pullapprove pullapprove bot requested a review from atscott April 30, 2021 09:05
@AndrewKushnir AndrewKushnir requested review from AndrewKushnir and removed request for atscott April 30, 2021 15:25
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix @crisbeto 👍

@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 30, 2021
crisbeto added a commit to crisbeto/angular that referenced this pull request Apr 30, 2021
These changes combine angular#41358 and angular#41894.

Currently we save a reference to an `LView` on most DOM nodes created by Angular either by saving the `LView` directly in the `__ngContext__` or by saving the `LContext` which has a reference to the `LView`. This can be a problem if the DOM node is retained in memory, because the `LView` has references to all of the child nodes of the view, as well as other internal data structures.

Previously we tried to resolve the issue by clearing the `__ngContext__` when a node is removed (see angular#36011), but we decided not to proceeed, because it can slow down destruction due to a megamorphic write.

These changes aim to address the issue while reducing the performance impact by assigning a unique ID when an `LView` is created and adding it to `__ngContext__`. All active views are tracked in a map where their unique ID is used as the key. We don't need to worry about leaks within that map,  because `LView`s are an internal data structure and we have complete control over when they are  created and destroyed.

Fixes angular#41047.
@crisbeto
Copy link
Member Author

Closing in favor of #41908.

@crisbeto crisbeto closed this Apr 30, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: presubmit The PR is in need of a google3 presubmit area: core Issues related to the framework runtime cla: yes target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants