Skip to content

[leak-scan] Routing.s_implicitPageRoutes — cancelled Shell push retains the page - #38404

Merged
kubaflo merged 3 commits into
dotnet:inflight/currentfrom
SubhikshaSf4851:Fix-38256
Sep 16, 2026
Merged

kubaflo merged 3 commits into
dotnet:inflight/currentfrom
SubhikshaSf4851:Fix-38256

Conversation

@SubhikshaSf4851

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment whether this change resolves your issue. Thank you!

This pull request improves the handling of implicit page routes during navigation, especially in scenarios where navigation is cancelled. The changes ensure that implicit routes are properly registered, unregistered, or restored, preventing route leaks or incorrect route assignments. Additionally, new unit tests are added to verify these behaviors.

Improvements to implicit route management:

  • Modified RegisterImplicitPageRoute in Routing to return any previously registered page for a given route, and added UnregisterImplicitPageRoute to restore or remove routes as needed.
  • Updated ShellNavigationManager.GoToAsync to track and restore displaced implicit routes if navigation is cancelled, ensuring that only the correct routes remain registered. [1] [2]

Testing and validation:

  • Added three new unit tests in ShellNavigatingTests to verify that cancelled navigation properly removes or restores implicit routes, including scenarios where the route changes during navigation.

Issues Fixed

Fixes #38256

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac
Before Issue Fix After Issue Fix
BeforeFix38256.mov
AfterFix38256.mov

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38404

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38404"

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Sep 10, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Sep 10, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

@SubhikshaSf4851 — new AI review results are available based on commit 4a66a96.

Gate Passed Confidence Low Platform Android


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: main · Merge base: 699f16e4

Test Without Fix (expect FAIL) With Fix (expect PASS)
🧪 ShellNavigatingTests ShellNavigatingTests ✅ FAIL — 116s ✅ PASS — 87s
🔴 Without fix — 🧪 ShellNavigatingTests: FAIL ✅ · 116s

Error-relevant lines (filtered from the build log):

     at Microsoft.Maui.Controls.Core.UnitTests.ShellNavigatingTests.CancelledPushRemovesImplicitRouteWhenPageRouteChangesDuringNavigation() in /_/src/Controls/tests/Core.UnitTests/ShellNavigatingTests.cs:line 122
     at Microsoft.Maui.Controls.Core.UnitTests.ShellNavigatingTests.CancelledPushRestoresDisplacedImplicitRoute() in /_/src/Controls/tests/Core.UnitTests/ShellNavigatingTests.cs:line 102
     at Microsoft.Maui.Controls.Core.UnitTests.ShellNavigatingTests.CancelledPushRemovesOnlyPushedPageImplicitRoute() in /_/src/Controls/tests/Core.UnitTests/ShellNavigatingTests.cs:line 81
🟢 With fix — 🧪 ShellNavigatingTests: PASS ✅ · 87s

(no coded error found; showing last 1200 chars)

ateCorrectly [1 ms]
  Passed MiddleRoutesAreRemovedWithoutPoppingStack [1 ms]
  Passed MultiplePopsRemoveMiddlePagesBeforeFinalPopWhenUsingModal [1 ms]
  Passed CancelledPushRestoresDisplacedImplicitRoute [1 ms]
  Passed PopToRootWithMultipleFlyoutItems [1 ms]
  Passed GlobalRoutesRegisteredHierarchicallyNavigateCorrectlyWithAdditionalItems [2 ms]
  Passed ShellContentOnlyWithGlobalEdit [1 ms]
  Passed GlobalRoutesRegisteredHierarchicallyWithDoublePop [1 ms]
  Passed NavigationPushAndPopBasic [1 ms]
  Passed AbsoluteRoutingToPage [2 ms]
  Passed CancelledPushRemovesOnlyPushedPageImplicitRoute [< 1 ms]
  Passed CancelNavigationOccurringOutsideGotoAsyncWithoutDelay [< 1 ms]
  Passed CancelNavigationOccurringOutsideGotoAsync [107 ms]
  Passed ShellSectionWithGlobalRouteAbsolute [1 ms]
  Passed HierarchicalNavigationWithBackNavigation [2 ms]
[xUnit.net 00:00:05.02]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed GlobalRoutesRegisteredHierarchicallyWithDoubleSplash [1 ms]
  Passed MultiplePopsRemoveMiddlePagesBeforeFinalPop [2 ms]
  Passed SwappingOutVisiblePageDoesntRevealPreviousPage [1 ms]
Test Run Successful.
Total tests: 55
     Passed: 55
 Total time: 5.5081 Seconds
📁 Fix files reverted (2 files)
  • src/Controls/src/Core/Routing.cs
  • src/Controls/src/Core/Shell/ShellNavigationManager.cs

📋 Pre-Flight — Context & Validation

PR #38404 Pre-Flight

Context

  • PR: [WIP][leak-scan] Routing.s_implicitPageRoutes — cancelled Shell push retains the page
  • Issue: #38256
  • Base/head: main / Fix-38256 (materialized locally as squashed commit 91498445f9)
  • Platform requested for review: Android
  • Gate: Passed previously; do not re-run or overwrite gate/content.md.

Problem

Shell.Navigation.PushAsync(page) registers an implicit route for PagePushing before raising the cancellable Navigating event. When navigation is cancelled, ShellNavigationManager.GoToAsync returns without removing that registration. The process-wide Routing.s_implicitPageRoutes dictionary then retains the cancelled page and its reachable object graph indefinitely unless a later successful navigation rebuilds the table.

Existing PR Approach

The PR implements transaction-like rollback around the eager registration:

  1. Routing.RegisterImplicitPageRoute now returns the page previously stored for the route.
  2. A new Routing.UnregisterImplicitPageRoute conditionally removes the cancelled page or restores the displaced page.
  3. ShellNavigationManager.GoToAsync captures the route and prior page before ProposeNavigation, then rolls back when cancellation is accepted.

This changes:

  • src/Controls/src/Core/Routing.cs
  • src/Controls/src/Core/Shell/ShellNavigationManager.cs
  • src/Controls/tests/Core.UnitTests/ShellNavigatingTests.cs

The implementation is managed and platform-independent; Android does not select a different production code path.

Detected Primary Test

Run only the three PR-added unit tests:

dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.ShellNavigatingTests.CancelledPush"

The selector covers:

  • CancelledPushRemovesOnlyPushedPageImplicitRoute
  • CancelledPushRestoresDisplacedImplicitRoute
  • CancelledPushRemovesImplicitRouteWhenPageRouteChangesDuringNavigation

No separate mandatory regression tests were listed in the STEP 5a request.

Candidate Constraints

  • Preserve the PR-added tests while EstablishBrokenBaseline.ps1 reverts only the two production fix files.
  • Modify only paths listed in .github/.baseline-state.json under RevertedFiles.
  • Candidate 1 must avoid the PR's captured-prior-value rollback mechanism.
  • Candidate 2 must additionally avoid Candidate 1's mechanism.
  • Each candidate gets one implementation/test pass and at most one focused correction/retest.
  • Restore exclusively with pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore.
  • Existing unrelated dirty/untracked workflow files are pre-existing workspace state and must remain untouched.

🔬 Code Review — Deep Analysis

Code Review — PR #38404

Independent Assessment

What this changes: The submitted fix makes the eager implicit-route registration used by Shell.Navigation.PushAsync(Page) reversible. It captures the route and any page displaced in Routing.s_implicitPageRoutes, then conditionally removes the pushed page or restores the displaced page when the cancellable Navigating proposal is rejected.

Inferred motivation: A cancelled push returns before the normal route-table rebuild, so the previous eager registration otherwise leaves the cancelled page reachable from process-wide static state.

Approach assessment: The rollback is localized to the operation that performed the eager registration, uses the registration-time route rather than a route that an event handler may mutate, and only rewrites the entry when it still points to the cancelled page. Returning the displaced page from the internal registration helper avoids adding longer-lived transaction state. The three focused tests cover independent-route removal, collision restoration, and route mutation during cancellation.

Reconciliation with PR Narrative

Author claims: Cancelled Shell pushes should remove or restore implicit routes so Routing.s_implicitPageRoutes does not retain the cancelled page or corrupt a displaced mapping.

Agreement/disagreement: The submitted code and tests match that claim. The implementation is shared Shell code; no Android-only production path is changed.

Prior Review Reconciliation

No prior ❌ Error findings found. The top-level review and inline-comment surfaces were empty; the four PR issue comments contained automation/dispatch messages only.

Blast Radius Assessment

  • Runs for all instances: The extra capture runs only for PagePushing navigation when no request was supplied; rollback runs only when that proposal is cancelled.
  • Startup impact: None; the code runs during Shell navigation.
  • Static/shared state: The affected implicit-route dictionary is process-wide, but the patch adds no new static state and invalidates the route-key cache after every actual rollback mutation.
  • Null/default behavior: The existing PagePushing guard prevents passing null to the new capture/rollback path.

CI Status

  • Required-check query: gh pr checks --required was unavailable because the CLI is unauthenticated.
  • Anonymous fallback: All 39 head check runs were complete; 38 succeeded and one unrelated Bump global.json job was skipped. The maui-pr run and Windows Helix unit-test runs succeeded, with no failed or pending check run.
  • Trusted gate: Passed — the focused tests fail without the production fix and pass with it.

Findings

No actionable findings. inline-findings.json contains an empty JSON array.

Failure-Mode Probing

  • Route changes during Navigating: Rollback uses pagePushingRoute, captured before the event, so it removes the original registration even after Routing.SetRoute changes the page's current route.
  • Another mapping replaces the same route before rollback: The ReferenceEquals guard preserves the newer mapping rather than overwriting it with stale state.
  • A prior page was displaced by the eager registration: Rollback restores that exact page, preserving the pre-navigation lookup result.
  • Navigation is accepted or uses an existing navigation request: Accepted navigation retains the existing eager registration behavior; an existing request never enters the new registration/rollback path.
  • Handler disconnect/reconnect and platform nullability: Not applicable; this is managed routing state with no handler or platform-view access.

External Output Contract

Not applicable.

Verdict: LGTM

Confidence: low
Summary: The submitted fix is internally consistent, narrowly scoped, and backed by regression tests that discriminate the important rollback cases. Confidence remains capped because the modified dictionary is process-wide shared navigation state, but no concrete blocking or discussion issue was found.


🛠️ Try-Fix — Analysis & Comparison

PR #38404 Try-Fix Aggregate

Candidate 1 — Routing-Owned Pending Registration Transaction

Result: Pass
Model: gpt-5.3-codex
Attempt artifacts: CustomAgentLogsTmp/PRState/38404/PRAgent/try-fix/attempt-1
Candidate narrative: CustomAgentLogsTmp/PRState/38404/PRAgent/try-fix-1/content.md

Approach

Routing.RegisterImplicitPageRoute records pending rollback metadata (the registration-time route and any displaced page) in a Page-keyed dictionary before updating the implicit-route table. ShellNavigationManager then signals rollback when navigation is cancelled or commit once navigation is accepted.

Prior PR Approach Avoided and Mechanism-Level Difference

The PR captures the route and displaced page in ShellNavigationManager.GoToAsync, then passes those values back to Routing for conditional removal/restoration. Candidate 1 avoids that caller-side capture and plumbing by making Routing own pending registration state. Its rollback uses the registration-time route snapshot, so a route change during Navigating does not prevent cleanup.

Files Changed

  • src/Controls/src/Core/Routing.cs
  • src/Controls/src/Core/Shell/ShellNavigationManager.cs

Test Results

Command:

dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.ShellNavigatingTests.CancelledPush"

First and only run passed: 3 passed, 0 failed, 0 skipped. No focused correction was needed.

Failure Analysis

N/A.

Inline Expert Self-Review

Clean: 0 findings.

Candidate Diff

diff --git a/src/Controls/src/Core/Routing.cs b/src/Controls/src/Core/Routing.cs
index f19062cd09..41121890ab 100644
--- a/src/Controls/src/Core/Routing.cs
+++ b/src/Controls/src/Core/Routing.cs
@@ -12,6 +12,7 @@ namespace Microsoft.Maui.Controls
 		static int s_routeCount = 0;
 		static Dictionary<string, RouteFactory> s_routes = new(StringComparer.Ordinal);
 		static Dictionary<string, Page> s_implicitPageRoutes = new(StringComparer.Ordinal);
+		static Dictionary<Page, PendingImplicitPageRouteRegistration> s_pendingImplicitPageRouteRegistrations = new();
 		static HashSet<string> s_routeKeys;
 
 		const string ImplicitPrefix = "IMPL_";
@@ -30,11 +31,41 @@ namespace Microsoft.Maui.Controls
 			var route = GetRoute(page);
 			if (!IsUserDefined(route))
 			{
+				s_implicitPageRoutes.TryGetValue(route, out var previousPage);
 				s_implicitPageRoutes[route] = page;
+				s_pendingImplicitPageRouteRegistrations[page] = new PendingImplicitPageRouteRegistration(route, previousPage);
 				s_routeKeys = null;
 			}
 		}
 
+		internal static void RollbackImplicitPageRouteRegistration(Page page)
+		{
+			if (!s_pendingImplicitPageRouteRegistrations.TryGetValue(page, out var pending))
+				return;
+
+			if (s_implicitPageRoutes.TryGetValue(pending.Route, out var registeredPage) &&
+				ReferenceEquals(registeredPage, page))
+			{
+				if (pending.PreviousPage is not null)
+				{
+					s_implicitPageRoutes[pending.Route] = pending.PreviousPage;
+				}
+				else
+				{
+					s_implicitPageRoutes.Remove(pending.Route);
+				}
+
+				s_routeKeys = null;
+			}
+
+			s_pendingImplicitPageRouteRegistrations.Remove(page);
+		}
+
+		internal static void CommitImplicitPageRouteRegistration(Page page)
+		{
+			s_pendingImplicitPageRouteRegistrations.Remove(page);
+		}
+
 		// Shell works much better if the entire nav stack can be represented by a string
 		// If the users pushes pages without using routes we want these page keys tracked
 		internal static void RegisterImplicitPageRoutes(Shell shell)
@@ -113,10 +144,23 @@ namespace Microsoft.Maui.Controls
 		internal static void Clear()
 		{
 			s_implicitPageRoutes.Clear();
+			s_pendingImplicitPageRouteRegistrations.Clear();
 			s_routes.Clear();
 			s_routeKeys = null;
 		}
 
+		readonly struct PendingImplicitPageRouteRegistration
+		{
+			public PendingImplicitPageRouteRegistration(string route, Page previousPage)
+			{
+				Route = route;
+				PreviousPage = previousPage;
+			}
+
+			public string Route { get; }
+			public Page PreviousPage { get; }
+		}
+
 		/// <summary>Bindable property for attached property <c>Route</c>.</summary>
 		public static readonly BindableProperty RouteProperty = CreateRouteProperty();
 
diff --git a/src/Controls/src/Core/Shell/ShellNavigationManager.cs b/src/Controls/src/Core/Shell/ShellNavigationManager.cs
index e21fcf1ea2..3ac911bace 100644
--- a/src/Controls/src/Core/Shell/ShellNavigationManager.cs
+++ b/src/Controls/src/Core/Shell/ShellNavigationManager.cs
@@ -52,7 +52,8 @@ namespace Microsoft.Maui.Controls
 			if (_shell?.CurrentItem?.CurrentItem?.PendingNavigationTask != null)
 				await (_shell?.CurrentItem?.CurrentItem?.PendingNavigationTask ?? Task.CompletedTask);
 
-			if (shellNavigationParameters.PagePushing != null && navigationRequest == null)
+			bool registeredPagePushingRoute = shellNavigationParameters.PagePushing is not null && navigationRequest is null;
+			if (registeredPagePushingRoute)
 				Routing.RegisterImplicitPageRoute(shellNavigationParameters.PagePushing);
 
 			var state = shellNavigationParameters.TargetState ?? new ShellNavigationState(Routing.GetRoute(shellNavigationParameters.PagePushing), false);
@@ -82,10 +83,18 @@ namespace Microsoft.Maui.Controls
 						accept = await navigatingArgs.DeferredTask;
 
 					if (!accept)
+					{
+						if (registeredPagePushingRoute)
+							Routing.RollbackImplicitPageRouteRegistration(shellNavigationParameters.PagePushing);
+
 						return;
+					}
 				}
 			}
 
+			if (registeredPagePushingRoute)
+				Routing.CommitImplicitPageRouteRegistration(shellNavigationParameters.PagePushing);
+
 			Routing.RegisterImplicitPageRoutes(_shell);
 
 			_accumulateNavigatedEvents = true;

Candidate 2

Result: Blocked
Model: gpt-5.6-sol
Attempt artifacts: CustomAgentLogsTmp/PRState/38404/PRAgent/try-fix/attempt-2
Candidate narrative: CustomAgentLogsTmp/PRState/38404/PRAgent/try-fix-2/content.md

Approach

Post-acceptance implicit-route registration. The planned change would defer inserting PagePushing into Routing.s_implicitPageRoutes until after the Navigating event is accepted. Routing.GetRoute(page) can still construct the navigation state before the event without retaining the page. Cancellation would return before any static-table mutation, while accepted navigation would register the page immediately before continuing.

Prior Approaches Avoided and Mechanism-Level Difference

The PR and Candidate 1 both mutate the static route table before the cancellation veto and compensate afterward. The PR stores rollback state in ShellNavigationManager; Candidate 1 stores it in a second Routing dictionary with explicit commit/rollback calls. Candidate 2 instead changes ordering so the veto occurs before mutation. If viable, cancellation cannot insert the page, displace an existing page, or strand an entry when the route changes during the event, and no rollback metadata is needed.

Files Changed

None. Baseline establishment failed before producing the mandatory RevertedFiles allow-list.

Test Results

Mandated command:

dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "FullyQualifiedName~Microsoft.Maui.Controls.Core.UnitTests.ShellNavigatingTests.CancelledPush"

Runs: 0. The test was not run because the candidate could not be applied to an established broken baseline.

Failure Analysis

pwsh .github/scripts/EstablishBrokenBaseline.ps1 rejected pre-existing unrelated tracked modifications under .github/scripts, .github/skills, and eng/scripts. It did not emit Baseline established, and .github/.baseline-state.json was absent. Without a RevertedFiles allow-list, the try-fix contract prohibited production edits. Cleaning the unrelated workspace state, bypassing the script, or using another restore mechanism was also prohibited, so the candidate was recorded as blocked.

The exact restore command still ran and reported No baseline state found / Restored False; this is the permitted no-state outcome because no production edit occurred.

Inline Expert Self-Review

Clean: 0 findings, with no candidate diff to review.

Candidate Diff

Aggregate Outcome

  • Candidate 1: Pass — empirically validated on all three primary tests.
  • Candidate 2: Blocked — distinct ordering-based design recorded, but not implemented or tested because baseline setup rejected unrelated pre-existing tracked changes.
  • Total candidates: 2.

📝 PR Finalize — Recommended Title & Description

Assessment: ✏️ Recommend updating — the title contains WIP/leak-scan noise and describes the symptom rather than the submitted rollback, while the description should state the eager-registration root cause and replace internal diffhunk:// references with self-contained details.

Recommended title

[Shell] Routing: Roll back implicit page registration when push navigation is cancelled

Recommended description

### Description of Change

`Shell.Navigation.PushAsync(page)` registers the page's implicit route before raising the cancellable `Navigating` event. When navigation is cancelled, `ShellNavigationManager.GoToAsync` returns before the normal implicit-route table rebuild, leaving the cancelled page and its reachable object graph retained by the process-wide `Routing.s_implicitPageRoutes` dictionary. A cancelled registration can also displace an existing page that uses the same implicit route.

This change makes that eager registration reversible:

* `Routing.RegisterImplicitPageRoute` now returns any page previously registered for the route.
* A new `Routing.UnregisterImplicitPageRoute` removes the cancelled page only when the route still maps to that page, restoring the displaced page when one existed.
* `ShellNavigationManager.GoToAsync` captures the registration-time route and displaced page before proposing navigation, then rolls back the registration when navigation is cancelled. Capturing the original route also allows cleanup when a `Navigating` handler changes the pushed page's route.

### Testing and validation

Added three `ShellNavigatingTests` unit tests covering:

* Removal of only the cancelled page's implicit route.
* Restoration of a displaced page that shared the implicit route.
* Cleanup of the registration-time route when the page route changes during `Navigating`.

### Issues Fixed

Fixes #38256

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194"> | <video src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843"> |

🏁 Report — Final Recommendation

✅ Final Recommendation: APPROVE

Winner: pr

The submitted PR is the strongest candidate. Its registration-time snapshot and guarded rollback directly address the leak, the trusted gate proves all three new tests fail without the production fix and the full 55-test ShellNavigatingTests run passes with it, the regression cross-reference is clean, current CI check runs have no failures, and the sole expert review found no actionable issue.

Comparative Ranking

Rank Candidate Implementation status Validation Assessment
1 pr Complete Gate: expected failure without fix; 55/55 ShellNavigatingTests passed with fix Winner. Uses operation-local rollback data, preserves a newer replacement via ReferenceEquals, restores a displaced page, and handles route mutation during Navigating without adding durable state.
2 pr-plus-reviewer Complete; identical to pr No separate run because the sole expert review produced no patch; inherits the submitted PR evidence Safe but not a distinct improvement. reviewer.patch is empty, so selecting it over the raw PR would misrepresent a no-op as a required change.
3 try-fix-1 Complete Focused command passed 3/3 tests Functionally passes the primary cases, but introduces s_pendingImplicitPageRouteRegistrations, another process-wide dictionary keyed by Page. Routine RegisterImplicitPageRoutes calls populate it for active pages without a matching commit, and ClearImplicitPageRoutes does not clear it; this recreates static retention risk and adds a fragile commit/rollback protocol. It also has narrower validation than the raw PR gate.
4 try-fix-2 Not implemented Blocked; 0 test runs The post-acceptance ordering idea avoids rollback state, but no diff or empirical evidence exists. A conceptual candidate cannot outrank complete candidates, particularly when eager registration participates in constructing/resolving the navigation request.

Why pr Wins

  1. Correctness: It rolls back exactly the registration made before the cancellable proposal and only if that mapping still belongs to the cancelled page.
  2. Regression evidence: The gate is discriminating and broader than the try-fix validation: all three added assertions fail against the broken production baseline, then the complete 55-test class passes with the submitted fix.
  3. State discipline: The rollback snapshot lives in local variables for one navigation operation. It does not add a second static page-retention structure or require future callers of RegisterImplicitPageRoute to participate in a transaction lifecycle.
  4. Review evidence: inline-findings.json is empty, prior review surfaces contain no error findings, and the deterministic regression-risk scan reports CLEAN.

Residual Risk

Routing.s_implicitPageRoutes remains process-wide shared state, so confidence is conservatively capped despite the clean review and validation. No concrete blocking or discussion item remains in the submitted diff, and the trusted Gate permits approval.


📱 UI Tests — Shell

Detected UI test categories: Shell

✅ Deep UI tests — 318 passed, 0 failed across 1 category on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
Shell 318/318 ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

🧭 Next Steps — review latest findings

No alternative fix was selected for this run. Review the session findings and CI results before merging.

@MauiBot MauiBot added s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Sep 10, 2026
@vishnumenon2684

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@SubhikshaSf4851 SubhikshaSf4851 changed the title [WIP][leak-scan] Routing.s_implicitPageRoutes — cancelled Shell push retains the page [leak-scan] Routing.s_implicitPageRoutes — cancelled Shell push retains the page Sep 15, 2026
@kubaflo
kubaflo marked this pull request as ready for review September 16, 2026 17:22
Copilot AI lite review requested due to automatic review settings September 16, 2026 17:22
@kubaflo
kubaflo changed the base branch from main to inflight/current September 16, 2026 17:23
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo
kubaflo merged commit 15f11e5 into dotnet:inflight/current Sep 16, 2026
151 of 169 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR12 milestone Sep 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes leaked implicit Shell page routes when navigation is cancelled by restoring or removing route registrations.

Changes:

  • Tracks displaced implicit routes during page pushes.
  • Removes or restores routes on cancellation.
  • Adds unit tests for route cleanup and restoration.
File summaries
File Description
src/Controls/tests/Core.UnitTests/ShellNavigatingTests.cs Updated as part of this pull request.
src/Controls/src/Core/Shell/ShellNavigationManager.cs Updated as part of this pull request.
src/Controls/src/Core/Routing.cs Updated as part of this pull request.
Review details

Suppressed comments (2)

src/Controls/src/Core/Routing.cs:50

  • The displaced page is restored under the captured key without checking that it still owns that route. A Navigating handler can call Routing.SetRoute(previousPage, ...) while the push is deferred; SetRoute only changes the attached property, so after cancellation this puts the page back in s_implicitPageRoutes[route] even though its current route is different, and later navigation to route resolves the wrong page. Before restoring, verify the previous page still has this route or rebuild/register the current implicit routes instead of restoring the stale entry.
				if (previousPage is not null)
				{
					s_implicitPageRoutes[route] = previousPage;

src/Controls/src/Core/Shell/ShellNavigationManager.cs:95

  • This rollback branch is also used by PushModalAsync (ShellSection.cs:1206-1212 sets PagePushing and calls this method), but the new tests only assert cleanup for a navigation-stack push. The existing CanCancelPushModalAsync test checks only that the modal stack is empty, so it would still pass if the implicit route leaked; add a canceled modal-push assertion for the page route (including the displaced-route case if applicable).
						if (registeredPagePushingRoute)
						{
							Routing.UnregisterImplicitPageRoute(shellNavigationParameters.PagePushing, pagePushingRoute, previousPagePushingRoute);
						}
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

{
if (registeredPagePushingRoute)
{
Routing.UnregisterImplicitPageRoute(shellNavigationParameters.PagePushing, pagePushingRoute, previousPagePushingRoute);
kubaflo pushed a commit that referenced this pull request Sep 18, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 21, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 27, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Sep 27, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Oct 3, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Oct 3, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Oct 6, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Oct 6, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Oct 13, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Oct 13, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Oct 14, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
kubaflo pushed a commit that referenced this pull request Oct 14, 2026
…ns the page (#38404)

<!-- Please keep the note below for people who find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!

This pull request improves the handling of implicit page routes during
navigation, especially in scenarios where navigation is cancelled. The
changes ensure that implicit routes are properly registered,
unregistered, or restored, preventing route leaks or incorrect route
assignments. Additionally, new unit tests are added to verify these
behaviors.

**Improvements to implicit route management:**

* Modified `RegisterImplicitPageRoute` in `Routing` to return any
previously registered page for a given route, and added
`UnregisterImplicitPageRoute` to restore or remove routes as needed.
* Updated `ShellNavigationManager.GoToAsync` to track and restore
displaced implicit routes if navigation is cancelled, ensuring that only
the correct routes remain registered.
[[1]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edL55-R62)
[[2]](diffhunk://#diff-8258a0822ba244b2e93e257647c9edd28bb117d146acb53e1889a4556c7734edR91-R100)

**Testing and validation:**

* Added three new unit tests in `ShellNavigatingTests` to verify that
cancelled navigation properly removes or restores implicit routes,
including scenarios where the route changes during navigation.


<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #38256 

### Tested the behavior in the following platforms

- [x] Windows
- [x] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/648b3be0-93b7-4d4b-871f-0011776f4194">
| <video
src="https://github.com/user-attachments/assets/10e45f87-f430-4427-bcac-ccfa58174843">
|
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 17, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 4a66a962 Deployed Sep 10, 2026 by SubhikshaSf4851 via conclusion #1841
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[leak-scan] Routing.s_implicitPageRoutes — cancelled Shell push retains the page

5 participants