-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios/catalyst] fix leak in NavigationPage
Fixes: #20119 PR #13833 fixed a leak in child pages of a `NavigationPage`, but it appears there are several cycles that would prevent the `NavigationPage` itself from going away. So, if you did something like this: // The original NavigationPage & children leak Application.Current.MainPage = new NavigationPage(new Page1()); Application.Current.MainPage = new Page2(); I could reproduce the same problem in a new device test. The cycles (and solutions) are: 1. `NavigationPage` -> `NavigationRenderer` -> `ParentingViewController` -> `NavigationPage` * Solution: make `_child` a `WeakReference` 2. `NavigationPage` -> `MenuItemTracker` -> `NavigationPage` * Solution: make `_target` a `WeakReference`, and `_additionalTargets` a `List<WeakReference>` 3. `NavigationPage` -> `MenuItemTracker.CollectionChanged` -> `NavigationPage` * Solution: subscribe/unsubscribe in `WillMoveToParentViewController` After these changes the sample app works, and the new device test passes.
- Loading branch information
1 parent
4a1c76c
commit b2dfc11
Showing
3 changed files
with
93 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters