Skip to content

Android: Stale ContainerView retains replaced FlyoutPage graph #35371

Description

@AdamEssenmacher

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

  1. Clone the repro branch:

    git clone --branch repro/android-stale-container-view-leak https://github.com/AdamEssenmacher/maui.git
    cd maui
  2. 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
  3. Launch the app:

    adb -s emulator-5554 shell monkey -p com.microsoft.maui.repros.androidstalecontainerviewleak 1
  4. In the app, tap Open FlyoutPage.

  5. Tap Return to monitor.

  6. Tap Force GC several times.

  7. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-navigationNavigationPagei/regressionThis issue described a confirmed regression on a currently supported versionplatform/androidregressed-in-10-preview1s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions