Description
On Android, replacing Window.Page from a FlyoutPage back to another page can leave the old FlyoutPage graph alive after forced GC.
The retained graph includes:
- the root
FlyoutPage
- the flyout
ContentPage
- the detail
NavigationPage
- the detail content page
The isolated root cause appears to be NavigationRootManager dropping its old _rootView reference without clearing the old Android ContainerView.CurrentView. That stale CurrentView keeps the previous FlyoutPage graph rooted.
Steps to Reproduce
-
Clone the repro branch:
git clone --branch repro/android-stale-container-view-leak https://github.com/AdamEssenmacher/maui.git
cd maui
-
Build and install the repro app on an Android emulator/device:
dotnet build src/Controls/samples/AndroidStaleContainerViewLeakRepro/Maui.Controls.AndroidStaleContainerViewLeakRepro.csproj -f net10.0-android -t:Install -p:AndroidDeviceSerial=emulator-5554
-
Launch the app:
adb -s emulator-5554 shell monkey -p com.microsoft.maui.repros.androidstalecontainerviewleak 1
-
In the app, tap Open FlyoutPage.
-
Tap Return to monitor.
-
Tap Force GC several times.
-
Observe the displayed counters.
Actual result on an unfixed build:
Tracked repro pages are still alive.
Root FlyoutPage: 1
Flyout ContentPage: 1
Detail NavigationPage:1
Detail ContentPage: 1
Weak refs alive: 4/4
Expected result:
No tracked repro pages are alive.
Root FlyoutPage: 0
Flyout ContentPage: 0
Detail NavigationPage:0
Detail ContentPage: 0
Weak refs alive: 0/4
Link to public reproduction project repository
https://github.com/AdamEssenmacher/maui/tree/repro/android-stale-container-view-leak/src/Controls/samples/AndroidStaleContainerViewLeakRepro
Version with bug
10.0.60
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
Description
On Android, replacing
Window.Pagefrom aFlyoutPageback to another page can leave the oldFlyoutPagegraph alive after forced GC.The retained graph includes:
FlyoutPageContentPageNavigationPageThe isolated root cause appears to be
NavigationRootManagerdropping its old_rootViewreference without clearing the old AndroidContainerView.CurrentView. That staleCurrentViewkeeps the previousFlyoutPagegraph rooted.Steps to Reproduce
Clone the repro branch:
git clone --branch repro/android-stale-container-view-leak https://github.com/AdamEssenmacher/maui.git cd mauiBuild and install the repro app on an Android emulator/device:
Launch the app:
In the app, tap
Open FlyoutPage.Tap
Return to monitor.Tap
Force GCseveral times.Observe the displayed counters.
Actual result on an unfixed build:
Expected result:
Link to public reproduction project repository
https://github.com/AdamEssenmacher/maui/tree/repro/android-stale-container-view-leak/src/Controls/samples/AndroidStaleContainerViewLeakRepro
Version with bug
10.0.60
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output