Skip to content

[Android] Modal page wrapped in NavigationPage is not garbage collected after PopModalAsync #34456

@Vetle444

Description

@Vetle444

Description

When a ContentPage is pushed as a modal wrapped in a NavigationPage via Navigation.PushModalAsync(new NavigationPage(page)), neither the NavigationPage, the inner ContentPage, nor any of their child views are garbage collected after calling PopModalAsync.

A plain modal page (without NavigationPage wrapping) is collected correctly.

This works correctly on iOS.

Image

Steps to Reproduce

  1. Clone https://github.com/Vetle444/MauiTestApp/tree/modalMemoryLeak
  2. Tap ModalPageNotCleanedUp
  3. Tap Push Modal Page in NavigationPage
  4. Close it
  5. Tap Force GC & Check Cleanup
  6. Notice that everything is still alive

Link to public reproduction project repository

https://github.com/Vetle444/MauiTestApp/tree/modalMemoryLeak

Version with bug

10.0.50

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.100 SR10

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Check PR in DIPS.Mobile.UI for workaround: DIPSAS/DIPS.Mobile.UI#818, specifically StackNavigationManagerWorkaround class

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