fix(core): remove application from the testability registry when the root view is removed#39876
fix(core): remove application from the testability registry when the root view is removed#39876arturovt wants to merge 2 commits intoangular:masterfrom arturovt:fix/22106
Conversation
AndrewKushnir
left a comment
There was a problem hiding this comment.
@arturovt, thanks for the PR, I've just left a couple comments. Thank you.
There was a problem hiding this comment.
FYI, I've checked the current size and it's 448229, so the delta introduced by this PR is 306 bytes (which I think is the case for other affected payload sizes as well). I don't see any symbols that become non-tree-shakable due to these changes, so I guess the size is coming from the names of new private fields (note: I'm not suggesting renaming them, just sharing observations with other reviewers).
|
I fixed up the code to make it consistent between Ivy and VE. @AndrewKushnir please have a look. |
|
@mhevery thanks, I will have a look and add extra tests as we discussed. I just noticed that the commit message is a bit strange: it refers to a different commit from master branch - could you please have a look when you get a chance? @arturovt just wanted to give a quick update: we've came across some inconsistencies in existing code while reviewing the changes in this PR and we went ahead with additional fixes:
I plan to add a couple more tests to verify the above-mentioned scenarios (and the one from #39365) and will push an extra commit. Please let us know if you're ok with us contributing to your PR (if you're not ok, we can revert our changes and create a separate PR). @arturovt it'd be helpful if you could also have a look at the changes in this PR (as original author of the changes) and let us know if you have any questions/feedback. Thank you. |
|
@AndrewKushnir I don't have any questions, looks great. Seems also great that it closes another issue simultaneously. |
…root view is removed In the new behavior Angular removes applications from the testability registry when the root view gets destroyed. This eliminates a memory leak, because before that the TestabilityRegistry holds references to HTML elements, thus they cannot be GCed. PR Close #22106
…f is destroyed This commit adds a few tests to verify that the `onDestroy` callbacks are invoked when `ComponentRef` instance is destroyed and the logic is consistent between ViewEngine and Ivy.
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: size-tracking
mhevery
left a comment
There was a problem hiding this comment.
reviewed-for: global-approvers
…root view is removed (#39876) In the new behavior Angular removes applications from the testability registry when the root view gets destroyed. This eliminates a memory leak, because before that the TestabilityRegistry holds references to HTML elements, thus they cannot be GCed. PR Close #22106 PR Close #39876
PR angular#39876 introduced an error where the `onDestroy` of `ComponentRef` would only get called if `ngDevMode` was set to true. This was because in dev mode we would freeze `TCleanup` to verify that no more static cleanup would get added to `TCleanup` array. This ensured that `TCleanup` was always present in dev mode. In production the `TCleanup` would get created only when needed. The resulting cleanup code was incorrectly indented and would only run if `TCleanup` was present causing this issue. Fix angular#40105
PR #39876 introduced an error where the `onDestroy` of `ComponentRef` would only get called if `ngDevMode` was set to true. This was because in dev mode we would freeze `TCleanup` to verify that no more static cleanup would get added to `TCleanup` array. This ensured that `TCleanup` was always present in dev mode. In production the `TCleanup` would get created only when needed. The resulting cleanup code was incorrectly indented and would only run if `TCleanup` was present causing this issue. Fix #40105 PR Close #40120
PR #39876 introduced an error where the `onDestroy` of `ComponentRef` would only get called if `ngDevMode` was set to true. This was because in dev mode we would freeze `TCleanup` to verify that no more static cleanup would get added to `TCleanup` array. This ensured that `TCleanup` was always present in dev mode. In production the `TCleanup` would get created only when needed. The resulting cleanup code was incorrectly indented and would only run if `TCleanup` was present causing this issue. Fix #40105 PR Close #40120
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
PR Type
What is the current behavior?
Issue Number: #22106
What is the new behavior?
In the new behavior Angular removes applications from the testability registry when the root view gets destroyed. This eliminates a memory leak, because before that the
TestabilityRegistryholds references to HTML elements, thus they cannot be GCed.Does this PR introduce a breaking change?