Skip to content

[net11.0][iOS] NavigationPage: respect back policy before interactive pop - #39574

Closed
kubaflo wants to merge 2 commits into
net11.0from
kubaflo-net11-back-gesture-failures
Closed

kubaflo wants to merge 2 commits into
net11.0from
kubaflo-net11-back-gesture-failures

Conversation

@kubaflo

@kubaflo kubaflo commented Oct 22, 2026

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 if this change resolves your issue. Thank you!

Description of Change

Fix the modern NavigationViewHandler interactive-pop path on the explicitly requested net11.0 branch. NavigationControllerManager.GestureDelegate.ShouldBegin checked the native stack depth but never consulted INavigationManagerDelegate.ShouldPop, so a page handling OnBackButtonPressed could not veto the gesture.

The manager now evaluates the existing back policy during gesture admission and reuses an accepted decision for UIKit's subsequent navbar callback, calling the application only once. Pending admission is cleared on navigation completion (including return to the original controller), disappearance, managed stack changes and disconnect. Root-stack rejection is retained and disconnected managers reject gesture admission. This follows the legacy renderer's completion/reset model without adding a new public API or a Controls dependency to Core.

The inherited device tests now obtain UINavigationController through IPlatformViewHandler, rather than requiring NavigationRenderer. They assert the callback count both immediately after admission and after the navbar callback. Additional theories cover actual native back-button allow/veto behavior and re-evaluating changed policy after returning to the current controller. Forcing the legacy renderer in the derived fixture would hide the product defect; evaluating policy independently in both callbacks would invoke application code twice.

This is the modern-manager follow-up to #38071, which changed the legacy NavigationRenderer/Shell paths, not NavigationControllerManager. No GC helpers, tolerances, XAML implementation, dependency pins or pipeline configuration are changed.

Validation

Supported hosted iOS CoreCLR: exact candidate 7a9b331b63781ab16e23c8f3ff1021f8b6130cba passed scoped build 1645892. Only the CoreCLR build and iOS Helix stages were selected; the seven other stages were confirmed completed/skipped. Actual uploaded xUnit XML was inspected, not just the pipeline result.

iOS Helix queue General XML Exact navigation cases
osx.15.arm64.maui.open 1246 passed, 10 skipped, 0 failures/errors 32/32 passed
osx.26.arm64.open 1242 passed, 14 skipped, 0 failures/errors 32/32 passed

The 32 cases per queue include both boolean variants of the two original theories and the two added theories across the base renderer, modern navigation handler, Flyout-handler and Tabbed-handler fixtures. None of these target cases was skipped.

The fixture-routing-only old-product control, build 1645755 at a4e530270296d7b0fa8289d14fa0c4cae6737623, exposed two underlying admission failures per queue: the modern handler returned true for handled back requests with either hidden or visible navigation bars. The other original variants passed. This is distinct from the earlier wrong-handler-type failure.

Additional limited local Mono causal controls: on an owned headless iPhone 11 Pro / iOS 26.5 simulator, with the final test source unchanged throughout, each arm ran three times:

Product state Actual native result on every repetition
Original product 52 passed / 6 intended failures
Fixed 58 passed / 0 failures
Fix reverted 52 passed / the same 6 failures
Fix restored 58 passed / 0 failures

All 58 test identities and the six failing identities/messages were reconciled across the 12 fresh XML files. The strengthened fixture detects four modern admission/callback failures plus two return/reset admission failures; it is therefore not described as the same suite/count as the older hosted routing-only control. Native back-button cases and legacy renderer controls pass in both red and green arms.

Local commands, using the pinned .NET SDK 11.0.100 (11.0.100-rtm.26514.118) and iOS workload 27.0.12230:

dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj \
  -t:Rebuild -f net11.0-ios -r iossimulator-arm64 -c Release -v:q \
  /p:IncludeIosTargetFrameworks=true \
  /p:IncludeAndroidTargetFrameworks=false \
  /p:IncludeMacCatalystTargetFrameworks=false \
  /p:UseMonoRuntime=true \
  /p:_DisableCheckForUnsupportedMonoMobileRuntime=true \
  /p:CodesignRequireProvisioningProfile=false \
  /p:TreatWarningsAsErrors=false \
  /p:ValidateXcodeVersion=false

Result: all four app rebuilds passed, with two existing warnings (MAUI1001 and the obsolete CollectionView handler warning). The Mono opt-in matches the existing CI smoke configuration. The local host has Xcode 26.6; the documented Xcode-version override is limited compatibility evidence, not supported-Xcode-27 certification. No linker/header/trimming bypass or dependency downgrade was used. The local CoreCLR app attempt failed with MT180; CoreCLR execution evidence comes from the supported hosted run above.

Each fresh arm/repetition used this XHarness command shape ($HEADLESS_MLAUNCH invokes the pinned bundled mlaunch with --quiet-simulator; $FRESH_OUTPUT is a new directory):

dotnet xharness apple test \
  --app artifacts/bin/Controls.DeviceTests/Release/net11.0-ios/iossimulator-arm64/Microsoft.Maui.Controls.DeviceTests.app \
  --target ios-simulator-64_26.5 \
  --device AA7BCC0E-CD5B-481A-BF91-402EB2CDFD6C \
  --mlaunch "$HEADLESS_MLAUNCH" \
  --output-directory "$FRESH_OUTPUT" \
  --timeout 00:10:00 --launch-timeout 00:02:00 \
  --set-env=TestFilter=Category=NavigationPage \
  --set-env=NUNIT_SKIPPED_CLASSES=Microsoft.Maui.DeviceTests.NavigationPageTests,Microsoft.Maui.DeviceTests.NavigationPageNavigationHandlerTests -v

Results: exit 1 with the six intended failures in every original/reverted run; exit 0 with 58/58 passing in every fixed/restored run. These were manual, constrained native controls, not a claim that the generic verification script emitted VERIFICATION PASSED.

Coverage limits: the return-to-current-controller test invokes the native DidShowViewController delegate callback; it is a cancellation-lifecycle control, not a physical canceled-swipe input test. No XCTest, Simulator GUI, host desktop UI automation, or MacCatalyst/Android/Windows test execution was used. The owned simulator was shut down afterward. The shared UIKit implementation also affects MacCatalyst, but native MacCatalyst execution is not claimed.

Ancestry/current-base limit: this branch and both hosted controls are based on b039b2b4bfd7fe2ffc024457af9c64265f1517d6, not the newer 7b0ea7800db3f3faccbaecb665d32b7c61eaf932. Neither edited file has a delta between those bases. The newer-base build 1645823 separately reports Essentials CA1416 errors in ImageProcessor/Passkeys. Those files are outside this PR; the successful scoped candidate run is not whole-current-base certification. No merge or rebase was used to obscure that distinction.

Issues Fixed

Related to #37781 and the pre-existing net11.0 navigation failures observed while validating #39536. This is a separate focused product fix; #39536 and its GC fixture are unchanged. No issue or unrelated PR is automatically closed by this description.

kubaflo and others added 2 commits October 22, 2026 19:36
Resolve the native navigation controller through IPlatformViewHandler and invoke the exported navbar callback for either implementation. Keep all back policy and exactly-once assertions unchanged for a hosted baseline control.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 90f92de8-cceb-42c6-89e1-42b0d7e90c0f
Evaluate back policy once when admitting a gesture, reuse that decision for the navbar callback, and clear it on navigation completion, disappearance, stack changes and disconnect. Add handler-neutral admission, callback-reset and native back-button coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 90f92de8-cceb-42c6-89e1-42b0d7e90c0f
Copilot AI balanced review requested due to automatic review settings October 22, 2026 20:17
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 22, 2026 20:17 — with GitHub Actions Inactive
@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 -- 39574

Or

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

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 22, 2026 20:17 — with GitHub Actions Inactive
@azure-pipelines

This comment has been minimized.

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.

🔵 Needs a closer look

Physical canceled-swipe behavior and shared MacCatalyst behavior remain unverified and warrant human review despite the reported iOS test results.

No open issues 🎉

What changed in this PR

Extends the back-navigation policy fix from #38071 to the modern NavigationViewHandler on net11.0, allowing pages to veto interactive pop gestures before UIKit starts navigation.

Changes:

  • Evaluates back policy during gesture admission and reuses accepted decisions to avoid duplicate callbacks.
  • Clears pending admission on navigation completion, disappearance, stack changes, and disposal.
  • Makes device tests handler-independent and adds native back-button and cancellation-reset coverage.
File Description
src/​Core/​src/​Platform/​iOS/​NavigationControllerManager/​NavigationControllerManager.cs Enforces gesture back policy and manages pending admission state.
src/​Controls/​tests/​DeviceTests/​Elements/​NavigationPage/​NavigationPageTests.iOS.cs Tests policy enforcement, callback counts, and reset behavior across handlers.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo kubaflo removed the s/agent-review-in-progress AI review is currently running for this PR label Oct 23, 2026
@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 23, 2026
@MauiBot

This comment has been minimized.

@kubaflo

kubaflo commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

/review expert-review

@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 Oct 23, 2026
@MauiBot

MauiBot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification for commit 7a9b331b.

Result INCONCLUSIVE Platform iOS Commit 7a9b331b


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

📱 Device tests
Test group Without fix With fix
NavigationPageTests (InteractivePopReturningToCurrentPageReevaluatesBackButtonPolicy, NativeBackButtonRespectsBackBut... ⚠ Build blocked ⚠ Build blocked
Execution log excerpts

Without fix NavigationPageTests (InteractivePopReturningToCurrentPageReevaluatesBackButtonPolicy, NativeBackButtonRespectsBackBut...

MSBuild : error MT180: This version of Microsoft.iOS requires the iOS 27.0 SDK (shipped with Xcode 27.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only in your project's iOS Build Options > Linker Behavior (to try to avoid the new APIs). [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj::TargetFramework=net11.0-ios]
Build FAILED.

With fix NavigationPageTests (InteractivePopReturningToCurrentPageReevaluatesBackButtonPolicy, NativeBackButtonRespectsBackBut...

MSBuild : error MT180: This version of Microsoft.iOS requires the iOS 27.0 SDK (shipped with Xcode 27.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only in your project's iOS Build Options > Linker Behavior (to try to avoid the new APIs). [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj::TargetFramework=net11.0-ios]
Build FAILED.

PR head: 7a9b331b.

Without-fix baseline: 4ef2769e.

@github-actions github-actions Bot 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.

Expert Review — 0 findings

Reviewed commit 7a9b331.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Oct 23, 2026
@kubaflo kubaflo closed this Oct 23, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 7a9b331b Deployed Oct 22, 2026 by kubaflo via conclusion #2473
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-navigation NavigationPage platform/ios platform/macos macOS / Mac Catalyst

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants