KEMBAR78
Fix for Handler not disconnected when removing a non-visible page from the navigation stack by praveenkumarkarunanithi · Pull Request #30049 · dotnet/maui · GitHub
Skip to content

Conversation

@praveenkumarkarunanithi
Copy link
Contributor

Root Cause

When Navigation.RemovePage() is used to remove a page from the navigation stack, the handler associated with the removed page is not disconnected. In contrast, methods like PopAsync() or PopModalAsync() trigger proper cleanup, including handler disconnection.

The RemovePage() method modifies the navigation stack without initiating any disposal or disconnection logic for the page's handler. As a result, the Handler property of the removed page remains assigned after removal, which can retain references to platform-specific resources.

Platform implementations do not consistently handle this scenario. On iOS, handler disconnection occur through ShellSectionRenderer.DisposePage() for some scenarios only, but this is not invoked as part of RemovePage(). On Android and Windows, no corresponding cleanup is performed when removing a page in this way.

Description of Change

This change ensures that when a page is removed from the navigation stack using RemovePage()—and the page is not currently visible—its handler is properly disconnected. The fix is implemented in NavigationProxy.OnRemovePage(), which provides a centralized and platform-agnostic location for handling page removal. This approach ensures consistent behavior across iOS, Android, and Windows, and correctly manages the page lifecycle by disconnecting the handler at the appropriate time.

Issues Fixed

Fixes #29923

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshots

Before Issue Fix After Issue Fix
withoutfix.mov
withfix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 18, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@praveenkumarkarunanithi! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 18, 2025
@praveenkumarkarunanithi praveenkumarkarunanithi added platform/macos macOS / Mac Catalyst platform/windows platform/android area-navigation NavigationPage platform/ios and removed community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Jun 18, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 18, 2025
@praveenkumarkarunanithi praveenkumarkarunanithi marked this pull request as ready for review June 19, 2025 09:39
@praveenkumarkarunanithi praveenkumarkarunanithi requested a review from a team as a code owner June 19, 2025 09:39
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current June 24, 2025 22:18
@PureWeen PureWeen merged commit 7c7df9f into dotnet:inflight/current Jun 24, 2025
128 of 130 checks passed
PureWeen pushed a commit that referenced this pull request Jun 25, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jun 26, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
PureWeen pushed a commit that referenced this pull request Jun 27, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
PureWeen pushed a commit that referenced this pull request Jun 28, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jun 29, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jun 29, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jul 1, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jul 2, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jul 2, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jul 8, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jul 8, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
github-actions bot pushed a commit that referenced this pull request Jul 9, 2025
…m the navigation stack (#30049)

* Update NavigationProxy.cs

* test case added

* Update Issue29923.cs

* fix updated
@github-actions github-actions bot locked and limited conversation to collaborators Jul 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-navigation NavigationPage partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android platform/ios platform/macos macOS / Mac Catalyst platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Removing page from navigation stack that is not the currently displayed page does not disconnect its handler

5 participants