Skip to content

[candidate/11 sr3] [Windows] Resume NavigationPage outside native completion callbacks (backport #40802) - #41239

Merged
kubaflo merged 1 commit into
candidate/11.0.1xx-sr3from
fix/sr3-navpage-windows-resume
Dec 4, 2026
Merged

kubaflo merged 1 commit into
candidate/11.0.1xx-sr3from
fix/sr3-navpage-windows-resume

Conversation

@kubaflo

@kubaflo kubaflo commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: bd031d6cce350ea841aada110490a62d8d4492d6

Dimension Assessment Rationale
Change confidence 8/10 ↑ Clean cherry-pick of merged main #40802 (2f147b3), identical to merged net11 port #41156.
↑ Local macOS: NavigationPageLifecycleTests 11/11 passed on this head.
↓ Windows-only code path not run locally; sr3 Windows devicetests pending on this PR.
Diagnosis confidence 8/10 ↑ sr3 314 build 1707806 unpackaged NavigationPage host exited 57005 during SettingTitleIconImageSourceDoesntCrash, the exact signature fixed by #40802.
↓ Original native faulting module still unknown.
Evidence fit 8.5/10 ↑ net11 build 1706822 with #41156: the same test Passed in both packaged and unpackaged NavigationPage TRX (16P/3S each).
↓ sr3 recurrence measured once (1707806); packaged leg did not crash in that run.

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

Backport of #40802 (cherry-pick of 2f147b3) to candidate/11.0.1xx-sr3. The same patch is already merged to net11 as #41156.

On Windows, WinUI completes NavigationPage navigation inside Loaded, where inline callers can immediately close the window. That crashes the test host. The fix resumes NavigationPage outside the native completion callback on Windows only. Other platforms keep their existing callback ordering, which a unit test now covers.

SR3 failure: In maui-pr-devicetests build 1707806, the "Windows controls unpackaged" NavigationPage category crashed with host exit code 57005 while SettingTitleIconImageSourceDoesntCrash was running (log 1068).

Issues Fixed

Unblocks sr3 maui-pr-devicetests Windows NavigationPage.

…40802)

<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `e9964a9acf9cfa240b69eba1155898bc524dcc6b`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 8/10 | ↑ Deferral is compiled only for Windows;
other platforms retain main's completion behavior.<br>↑ 350 navigation
unit tests pass, including the non-Windows ordering regression
test.<br>↑ Build 1704240 validates iOS General and Windows
NavigationPage in both packaging modes at this exact head.<br>↓ The
first scoped-head run still had iOS failures; an unchanged-head retry
passed, so native environment variability remains relevant. |
| Diagnosis confidence | 7/10 | ↑ WinUI completes navigation inside
Loaded, where inline callers can immediately close the window.<br>↑ The
Windows-only change retains success of the original crash test in both
packaging modes.<br>↑ Non-Windows callback ordering is restored and
unit-tested.<br>↓ The original Windows native faulting module is
unknown; the 17 iOS failures cannot all be causally attributed to
deferral, since they also occurred once with this scoped head. |
| Evidence fit | 8/10 | ↑ Build 1704240 genuine TRX: iOS General 1479
passed/0 failed/14 existing skips, including all 17 previously failing
cases.<br>↑ Both Windows NavigationPage categories: 16 passed/0 failed/3
existing skips, and the original test explicitly Passed (242 ms
packaged, 240 ms unpackaged).<br>↓ Build 1704232's first scoped-head iOS
result was red; the green validation is the unchanged-head retry
1704240, not that earlier run. |
<!-- /copilot-assessment -->

<!-- Please let the below note in for people that 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 if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting):
`main`, explicitly requested for the .NET 12 Windows CI failure.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

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

On **Windows only**, create the active `NavigationPage` request
completion source with `RunContinuationsAsynchronously`. Other platforms
retain the original completion source and native callback ordering.

On Windows, `StackNavigationManager.OnNavigated` completes the request
from WinUI's `Loaded` callback. Previously, `SetResult` could
synchronously run the entire navigation continuation and its caller
while that native callback was still on the stack. In
`SettingTitleIconImageSourceDoesntCrash`, this includes updating the
toolbar image and immediately closing/destroying the window through
`CreateHandlerAndAddToWindow`. Queueing continuations lets the native
completion callback unwind first.

The updated portable unit test uses a manually completed handler and
verifies that non-Windows `NavigatedTo` retains its original synchronous
native callback ordering. It fails against this PR's earlier unscoped
deferral and passes with the Windows-only correction. The existing
Windows device test is unchanged: no skip, delay, image substitution, or
reduced coverage.

Baseline: [build
1704198](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1704198),
Windows Controls packaged [log
760](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1704198/logs/760?api-version=7.1),
11:38:15–11:38:38 UTC. The recovered TRX contains one passed test; the
sequence starts `SettingTitleIconImageSourceDoesntCrash` without an end
event. The process exits 57005 (0xDEAD), MTP exits 7. The artifact
contains no `.dmp`, and `windows-application-events.json` is empty. No
faulting module or native exception is known. The supplied additional
baseline builds are 1704155, 1703964 and 1704185.

Duplicate search covered open and recently merged PRs across main,
net11, release, candidate and inflight branches for this test, title
icons, PageControl, StackNavigationManager, teardown, and navigation
continuations. This is not #40795's initial-navigation event guard
(already on main), nor #39911's stale image-result guard (also already
on main).

Validation (latest revision, configured SDK
`12.0.100-alpha.1.26523.103`, macOS):

```sh
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj \
  -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false \
  -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false \
  -p:IncludeWindowsTargetFrameworks=false \
  --filter-method '*NonWindowsNavigationCompletionPreservesNativeCallbackOrdering' --verbosity quiet
```

- Before scoping the fix: **failed**, `Assert.True`, actual `False` (1
test), proving the unscoped PR changes non-Windows ordering.
- After scoping, same command with `--filter-method '*Navigation*'`:
**passed**, 350/350.
- `dotnet format whitespace --folder --include
src/Controls/src/Core/NavigationPage/NavigationPage.cs
src/Controls/tests/Core.UnitTests/NavigationPageLifecycleTests.cs
--verbosity quiet`: **passed**.
- `git diff --check`: **passed**.
- Latest-head native iOS/Windows CI: **validated in build 1704240**
below; not run locally.

#### Native CI history and regression correction

[Build
1704212](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1704212)
tested the **previous** head `c4da77aa65cbec06d93b41a8c4b0b6ae69f219e6`
(merge `6da2433c9f8cde06366718a44c461b11bc97caf7`):

- Windows NavigationPage passed in both modes: 16 passed, 0 failed, 3
existing skips each. Both genuine TRX files explicitly mark
`SettingTitleIconImageSourceDoesntCrash` Passed (148 ms packaged, 189 ms
unpackaged). [Packaged log
760](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1704212/logs/760?api-version=7.1);
[unpackaged log
739](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1704212/logs/739?api-version=7.1).
- **Observed failures:** iOS Controls CoreCLR General [log
727](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1704212/logs/727?api-version=7.1)
failed 17/1493 tests: TabbedPage background transitions, NavigationPage
back-button observation, More-tab PageTransitions, and ScrollView
horizontal options. The unscoped deferral changed non-Windows callback
ordering (confirmed by the unit test); this revision restores main's
behavior outside Windows. The 17 native failures are not conclusively
all caused by that ordering change: they also recurred in the first
Windows-only run before passing on the unchanged-head retry.
- The reported Windows unpackaged Shell crash and Windows BlazorWebView
initialization failure also occur on main / are known flakes; they are
outside this fix and are not modified or hidden.
- Build 1704210 was canceled before execution and is not validation
evidence.

#### Latest-head native validation: build 1704240

[Build
1704240](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1704240)
validates head `e9964a9acf9cfa240b69eba1155898bc524dcc6b` through merge
`4edb3a18f4e96fe3be0f866b887b506e1a42a221`.

| Selected coverage | Actual result | Raw task log |
| --- | --- | --- |
| iOS Controls CoreCLR General | 1479 passed, 0 failed, 14 existing
skips; job succeeded |
[736](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1704240/logs/736?api-version=7.1)
|
| Windows Controls packaged NavigationPage | 16 passed, 0 failed, 3
existing skips; category exit 0 |
[745](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1704240/logs/745?api-version=7.1)
|
| Windows Controls unpackaged NavigationPage | 16 passed, 0 failed, 3
existing skips; category exit 0 |
[739](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1704240/logs/739?api-version=7.1)
|

The genuine iOS `native/testResults.trx` confirms all 17 previously
failing cases individually **Passed**. Both Windows
`categories/NavigationPage/Controls-NavigationPage.trx` files explicitly
record `SettingTitleIconImageSourceDoesntCrash` **Passed** (242 ms
packaged, 240 ms unpackaged). No native device tests were changed or
newly skipped.

**First-run caveat:** build 1704232 tested the same scoped head and
still had the same 17 iOS failures (log 736), despite compiling IOS
rather than WINDOWS and retaining main's non-Windows code. Compared with
green main 1704155, its simulator log records a different iOS 27.2
runtime build (`SimulatorRuntime-v24.2.91016.19` versus `v24.2.8117.0`),
and provisioning ends with `Data Migration Failed`. These differences
support native environment variability, not a proven root cause of every
failure. The subsequent 1704240 run was an **unchanged-head retry**, not
another product fix.

The packaged Windows job in 1704240 still fails in the separate Shell
category (exit 7); NavigationPage passes. The known Shell/BlazorWebView
failures are not fixed or hidden here. This is validation of the
requested iOS General and Windows NavigationPage coverage, not a
full-CI-green claim.

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

Addresses the Windows Controls `SettingTitleIconImageSourceDoesntCrash`
CI host crash described above; no separate issue was supplied. Related
investigation: #40795, not a replacement or duplicate of its net11 fix.

### Let AI finish this PR

- [ ] **Let the MAUI agent address review feedback and fix remaining
issues on this PR.** Maintainers still decide whether it is merged. For
PRs from forks, the agent opens a follow-up PR that keeps your commits.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 2f147b3)
@kubaflo

kubaflo commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto stamp

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Stamping as requested by @kubaflo; no code review performed.

@kubaflo
kubaflo merged commit 48fe132 into candidate/11.0.1xx-sr3 Dec 4, 2026
7 of 16 checks passed
@kubaflo
kubaflo deleted the fix/sr3-navpage-windows-resume branch December 4, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants