Skip to content

[iOS, MacCatalyst] Fix Shell flyout header layout when bound text changes - #39877

Merged
kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr2from
SyedAbdulAzeemSF4852:fix-39739
Nov 12, 2026
Merged

kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr2from
SyedAbdulAzeemSF4852:fix-39739

Conversation

@SyedAbdulAzeemSF4852

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!

Issue Details

  • In the Shell Flyout Header, the second Label bound to a ViewModel property fails to calculate its correct height when its Text changes from null to a long string at runtime, causing the text to appear empty, get clipped, or fail to wrap properly.

Root Cause

  • PR [IOS] Inconsistent Resize Behavior for Header/Footer - fix #28713 introduced synchronous measurement during Shell flyout header invalidation, which can occur before the label’s property mapper updates its native text. This could cache stale measurements. Reassigning an unchanged header frame also did not reliably schedule layout, leaving child labels with empty or incorrect native frames.

Description of Change

  • Updated the InvalidateMeasure implementation in ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of immediately recalculating and setting the frame, ensuring that native view updates are properly handled before layout occurs.
  • Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child measurements before arranging them, even if the header size remains unchanged.

Issues Fixed

Fixes #39739

Validated the behaviour in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Platform Before Fix After Fix
iOS
Before.mov
After.mov
Mac
Mac_Before.mov
Mac_After.mov

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Nov 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@azure-pipelines

This comment has been minimized.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

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 -- 39877

Or

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

@vishnumenon2684

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@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 Nov 4, 2026

@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 c7b5564.

@MauiBot

This comment has been minimized.

@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 Nov 6, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@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 a2012e3.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 6, 2026

@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 8714383.

@MauiBot

MauiBot commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@SyedAbdulAzeemSF4852 — existing-test verification for commit 87143838.

Result SKIPPED Platform Android Commit 87143838


🧪 Gate analysis — click to expand

⚠ Skipped. No runnable PR tests were selected. The fix has not been verified by this gate.

No interpretable test-group summary was produced. No additional test execution is inferred.

PR head: 87143838.

Without-fix baseline: 9291bfb2.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 12, 2026
@kubaflo
kubaflo changed the base branch from main to candidate/11.0.1xx-sr2 November 12, 2026 11:49
@kubaflo
kubaflo merged commit 7cda2bd into dotnet:candidate/11.0.1xx-sr2 Nov 12, 2026
153 of 177 checks passed
kubaflo added a commit that referenced this pull request Nov 13, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 17, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 20, 2026
… device tests (#40486)

<!-- 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).

This is SR2 candidate integration work for #40116, so it targets
`candidate/11.0.1xx-sr2`. #40457 was merged straight into the candidate
(0eb47dd) and `net11` doesn't have it, so there is nothing to revert
on `net11`.

### Description of Change

This reverts #40457 ("Window: Disconnect page handlers when the window
is destroyed"), which crashes the Controls device-test apps on Android,
iOS and Windows and leaves MacCatalyst Controls device tests without
results.

#40457 changed `Window.Destroying()` to disconnect the handlers of the
window's page and modal stack. Platform callbacks still run after
`Destroying()`, and when they reach the now-disconnected handlers the
process crashes:

| Platform | Crash | Stack |
| --- | --- | --- |
| iOS (CoreCLR + Mono, iOS 18 and 26 queues),
Controls.DeviceTests-General | `InvalidOperationException: Page cannot
be null here` | `ControlsModalWrapper.UpdateBackgroundColor` ←
`ControlsModalWrapper.ViewWillAppear` (the modal is dismissed after
window teardown) |
| iOS (CoreCLR + Mono), Controls.DeviceTests-Shell |
`InvalidOperationException: VirtualView cannot be null here` |
`ShellPageRendererTracker.Dispose` ← `ShellSectionHandler.DisposePage` ←
`OnPopRequested` |
| Android (CoreCLR + Mono), API 33 | `ArgumentNullException` for
`context` | `ShellSectionRenderer.OnCreateView`. A pending fragment
transaction runs after teardown, and `FindMauiContext()` returns null. |
| Windows (packaged + unpackaged) | `0xc000027b`, faulting module
`Microsoft.UI.Xaml.dll` | Process crash during the Controls device tests
(attributed by mechanism; not reproduced locally) |
| MacCatalyst (CoreCLR, osx.15 + osx.26) | No test results | osx.15
`Controls Tests` ran into the 3600 s XHarness timeout (exit 94,
`TEST_RESULTS_MISSING`; the app was still alive). On osx.26 the app
exited after about 6 minutes with no results file, and XHarness still
reported success. Without #40457, both queues report 1636–1777 tests in
about 12 minutes (8 runs in builds 1690816, 1692066, 1692670, 1692736).
Attributed by correlation; not reproduced locally. |

**CI** (`maui-pr-devicetests` on the candidate branch):

| Build | Candidate head | Contains #40457 | Result |
| --- | --- | --- | --- |
|
[1692670](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1692670)
| b828f7b | no | Controls device tests passed |
|
[1692843](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1692843)
| e064224 | yes | Helix work items crash: iOS General + Shell on all
four iOS legs; Android CoreCLR + Mono; Windows packaged + unpackaged;
MacCatalyst `Controls Tests` produced no results on either queue |

The revert is a full `git revert` of 0eb47dd (5 files, +2/−214). It
restores `Window.cs` and removes the tests #40457 added:
- `BlazorWebViewTests.WindowDestroying.cs` and
`DisposalTrackingComponent.razor`;
- the `WindowsTests` and `ModalNavigationPlatformTests` unit tests for
the destroy-disconnect behavior.

These tests are removed together with the behavior they assert. No
unrelated test is changed.

#40457 merged without a `maui-pr-devicetests` run, so these crashes
first showed up after it landed on the candidate.

### Local evidence

Each run starts from candidate head a6d3ad9. The "re-apply" step
reverts the revert (`git revert --no-commit HEAD`), which gives back a
tree byte-identical to a6d3.

**iOS, `Category=Modal`** (CoreSimulator iPhone 16 Pro, iOS 26.5):

| Step | Result |
| --- | --- |
| a6d3 (with #40457) | RED: APP_CRASH, `Page cannot be null here` from
`ControlsModalWrapper.UpdateBackgroundColor` |
| This revert | GREEN: 222/222 passed |
| Re-apply #40457 | RED: same exception |
| Revert restored | GREEN: 222/222 passed |

**Android, `Category=Shell`** (emulator API 35, arm64):

| Step | Result |
| --- | --- |
| a6d3 (with #40457) | RED: APP_CRASH (XHarness exit 80), FATAL
`ArgumentNullException: context` at `ShellSectionRenderer.OnCreateView`,
right after `FlyoutContentUpdatesAfterChange` (identical to CI) |
| This revert | No crash |
| Re-apply #40457 | RED: same FATAL |
| Revert restored | GREEN: 197/197 passed, XHarness exit 0, no FATAL |

The first revert run had 4 `ShellRendererTransitionTests` failures
(193/197). They didn't come back when the revert was restored (197/197),
so they're intermittent and unrelated to this change.

**iOS, `Category=Shell`** on this branch: no crash; the `VirtualView
cannot be null here` path is gone.
- On iOS 26.5,
`FlyoutHeaderLabelsAreArrangedWhenBoundTextChangesWithoutResizingHeader`
(#39877) failed 2/552. It is a layout assertion, and this PR doesn't
touch layout.
- The same `Category=Shell` run on an iPhone 11 Pro **iOS 18.5**
simulator (the device CI uses is iPhone 11 Pro, iOS 18.1) passed
552/552, XHarness exit 0.
- CI b828 also passed that test on iOS. So the iOS 26.5 failure is
local-environment only and unrelated to this revert.

### Re-landing #40056's fix

The BlazorWebView disposal leak from #40056 is still worth fixing. A
re-land needs to tolerate callbacks that arrive after
`Window.Destroying()`:
- the iOS modal wrapper's `ViewWillAppear`/dismissal;
- Android fragment transactions that are still pending;
- Windows window close.

It should also run `maui-pr-devicetests` (Controls: Modal, Shell,
General) on all platforms before merging. cc @Kebechet

### Issues Fixed

Relates to #40056 and #40116

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
… device tests (#40486)

<!-- 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).

This is SR2 candidate integration work for #40116, so it targets
`candidate/11.0.1xx-sr2`. #40457 was merged straight into the candidate
(0eb47dd) and `net11` doesn't have it, so there is nothing to revert
on `net11`.

### Description of Change

This reverts #40457 ("Window: Disconnect page handlers when the window
is destroyed"), which crashes the Controls device-test apps on Android,
iOS and Windows and leaves MacCatalyst Controls device tests without
results.

#40457 changed `Window.Destroying()` to disconnect the handlers of the
window's page and modal stack. Platform callbacks still run after
`Destroying()`, and when they reach the now-disconnected handlers the
process crashes:

| Platform | Crash | Stack |
| --- | --- | --- |
| iOS (CoreCLR + Mono, iOS 18 and 26 queues),
Controls.DeviceTests-General | `InvalidOperationException: Page cannot
be null here` | `ControlsModalWrapper.UpdateBackgroundColor` ←
`ControlsModalWrapper.ViewWillAppear` (the modal is dismissed after
window teardown) |
| iOS (CoreCLR + Mono), Controls.DeviceTests-Shell |
`InvalidOperationException: VirtualView cannot be null here` |
`ShellPageRendererTracker.Dispose` ← `ShellSectionHandler.DisposePage` ←
`OnPopRequested` |
| Android (CoreCLR + Mono), API 33 | `ArgumentNullException` for
`context` | `ShellSectionRenderer.OnCreateView`. A pending fragment
transaction runs after teardown, and `FindMauiContext()` returns null. |
| Windows (packaged + unpackaged) | `0xc000027b`, faulting module
`Microsoft.UI.Xaml.dll` | Process crash during the Controls device tests
(attributed by mechanism; not reproduced locally) |
| MacCatalyst (CoreCLR, osx.15 + osx.26) | No test results | osx.15
`Controls Tests` ran into the 3600 s XHarness timeout (exit 94,
`TEST_RESULTS_MISSING`; the app was still alive). On osx.26 the app
exited after about 6 minutes with no results file, and XHarness still
reported success. Without #40457, both queues report 1636–1777 tests in
about 12 minutes (8 runs in builds 1690816, 1692066, 1692670, 1692736).
Attributed by correlation; not reproduced locally. |

**CI** (`maui-pr-devicetests` on the candidate branch):

| Build | Candidate head | Contains #40457 | Result |
| --- | --- | --- | --- |
|
[1692670](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1692670)
| b828f7b | no | Controls device tests passed |
|
[1692843](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1692843)
| e064224 | yes | Helix work items crash: iOS General + Shell on all
four iOS legs; Android CoreCLR + Mono; Windows packaged + unpackaged;
MacCatalyst `Controls Tests` produced no results on either queue |

The revert is a full `git revert` of 0eb47dd (5 files, +2/−214). It
restores `Window.cs` and removes the tests #40457 added:
- `BlazorWebViewTests.WindowDestroying.cs` and
`DisposalTrackingComponent.razor`;
- the `WindowsTests` and `ModalNavigationPlatformTests` unit tests for
the destroy-disconnect behavior.

These tests are removed together with the behavior they assert. No
unrelated test is changed.

#40457 merged without a `maui-pr-devicetests` run, so these crashes
first showed up after it landed on the candidate.

### Local evidence

Each run starts from candidate head a6d3ad9. The "re-apply" step
reverts the revert (`git revert --no-commit HEAD`), which gives back a
tree byte-identical to a6d3.

**iOS, `Category=Modal`** (CoreSimulator iPhone 16 Pro, iOS 26.5):

| Step | Result |
| --- | --- |
| a6d3 (with #40457) | RED: APP_CRASH, `Page cannot be null here` from
`ControlsModalWrapper.UpdateBackgroundColor` |
| This revert | GREEN: 222/222 passed |
| Re-apply #40457 | RED: same exception |
| Revert restored | GREEN: 222/222 passed |

**Android, `Category=Shell`** (emulator API 35, arm64):

| Step | Result |
| --- | --- |
| a6d3 (with #40457) | RED: APP_CRASH (XHarness exit 80), FATAL
`ArgumentNullException: context` at `ShellSectionRenderer.OnCreateView`,
right after `FlyoutContentUpdatesAfterChange` (identical to CI) |
| This revert | No crash |
| Re-apply #40457 | RED: same FATAL |
| Revert restored | GREEN: 197/197 passed, XHarness exit 0, no FATAL |

The first revert run had 4 `ShellRendererTransitionTests` failures
(193/197). They didn't come back when the revert was restored (197/197),
so they're intermittent and unrelated to this change.

**iOS, `Category=Shell`** on this branch: no crash; the `VirtualView
cannot be null here` path is gone.
- On iOS 26.5,
`FlyoutHeaderLabelsAreArrangedWhenBoundTextChangesWithoutResizingHeader`
(#39877) failed 2/552. It is a layout assertion, and this PR doesn't
touch layout.
- The same `Category=Shell` run on an iPhone 11 Pro **iOS 18.5**
simulator (the device CI uses is iPhone 11 Pro, iOS 18.1) passed
552/552, XHarness exit 0.
- CI b828 also passed that test on iOS. So the iOS 26.5 failure is
local-environment only and unrelated to this revert.

### Re-landing #40056's fix

The BlazorWebView disposal leak from #40056 is still worth fixing. A
re-land needs to tolerate callbacks that arrive after
`Window.Destroying()`:
- the iOS modal wrapper's `ViewWillAppear`/dismissal;
- Android fragment transactions that are still pending;
- Windows window close.

It should also run `maui-pr-devicetests` (Controls: Modal, Shell,
General) on all platforms before merging. cc @Kebechet

### Issues Fixed

Relates to #40056 and #40116

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…nges (#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR #28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes #39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
… device tests (#40486)

<!-- 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).

This is SR2 candidate integration work for #40116, so it targets
`candidate/11.0.1xx-sr2`. #40457 was merged straight into the candidate
(0eb47dd) and `net11` doesn't have it, so there is nothing to revert
on `net11`.

### Description of Change

This reverts #40457 ("Window: Disconnect page handlers when the window
is destroyed"), which crashes the Controls device-test apps on Android,
iOS and Windows and leaves MacCatalyst Controls device tests without
results.

#40457 changed `Window.Destroying()` to disconnect the handlers of the
window's page and modal stack. Platform callbacks still run after
`Destroying()`, and when they reach the now-disconnected handlers the
process crashes:

| Platform | Crash | Stack |
| --- | --- | --- |
| iOS (CoreCLR + Mono, iOS 18 and 26 queues),
Controls.DeviceTests-General | `InvalidOperationException: Page cannot
be null here` | `ControlsModalWrapper.UpdateBackgroundColor` ←
`ControlsModalWrapper.ViewWillAppear` (the modal is dismissed after
window teardown) |
| iOS (CoreCLR + Mono), Controls.DeviceTests-Shell |
`InvalidOperationException: VirtualView cannot be null here` |
`ShellPageRendererTracker.Dispose` ← `ShellSectionHandler.DisposePage` ←
`OnPopRequested` |
| Android (CoreCLR + Mono), API 33 | `ArgumentNullException` for
`context` | `ShellSectionRenderer.OnCreateView`. A pending fragment
transaction runs after teardown, and `FindMauiContext()` returns null. |
| Windows (packaged + unpackaged) | `0xc000027b`, faulting module
`Microsoft.UI.Xaml.dll` | Process crash during the Controls device tests
(attributed by mechanism; not reproduced locally) |
| MacCatalyst (CoreCLR, osx.15 + osx.26) | No test results | osx.15
`Controls Tests` ran into the 3600 s XHarness timeout (exit 94,
`TEST_RESULTS_MISSING`; the app was still alive). On osx.26 the app
exited after about 6 minutes with no results file, and XHarness still
reported success. Without #40457, both queues report 1636–1777 tests in
about 12 minutes (8 runs in builds 1690816, 1692066, 1692670, 1692736).
Attributed by correlation; not reproduced locally. |

**CI** (`maui-pr-devicetests` on the candidate branch):

| Build | Candidate head | Contains #40457 | Result |
| --- | --- | --- | --- |
|
[1692670](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1692670)
| b828f7b | no | Controls device tests passed |
|
[1692843](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1692843)
| e064224 | yes | Helix work items crash: iOS General + Shell on all
four iOS legs; Android CoreCLR + Mono; Windows packaged + unpackaged;
MacCatalyst `Controls Tests` produced no results on either queue |

The revert is a full `git revert` of 0eb47dd (5 files, +2/−214). It
restores `Window.cs` and removes the tests #40457 added:
- `BlazorWebViewTests.WindowDestroying.cs` and
`DisposalTrackingComponent.razor`;
- the `WindowsTests` and `ModalNavigationPlatformTests` unit tests for
the destroy-disconnect behavior.

These tests are removed together with the behavior they assert. No
unrelated test is changed.

#40457 merged without a `maui-pr-devicetests` run, so these crashes
first showed up after it landed on the candidate.

### Local evidence

Each run starts from candidate head a6d3ad9. The "re-apply" step
reverts the revert (`git revert --no-commit HEAD`), which gives back a
tree byte-identical to a6d3.

**iOS, `Category=Modal`** (CoreSimulator iPhone 16 Pro, iOS 26.5):

| Step | Result |
| --- | --- |
| a6d3 (with #40457) | RED: APP_CRASH, `Page cannot be null here` from
`ControlsModalWrapper.UpdateBackgroundColor` |
| This revert | GREEN: 222/222 passed |
| Re-apply #40457 | RED: same exception |
| Revert restored | GREEN: 222/222 passed |

**Android, `Category=Shell`** (emulator API 35, arm64):

| Step | Result |
| --- | --- |
| a6d3 (with #40457) | RED: APP_CRASH (XHarness exit 80), FATAL
`ArgumentNullException: context` at `ShellSectionRenderer.OnCreateView`,
right after `FlyoutContentUpdatesAfterChange` (identical to CI) |
| This revert | No crash |
| Re-apply #40457 | RED: same FATAL |
| Revert restored | GREEN: 197/197 passed, XHarness exit 0, no FATAL |

The first revert run had 4 `ShellRendererTransitionTests` failures
(193/197). They didn't come back when the revert was restored (197/197),
so they're intermittent and unrelated to this change.

**iOS, `Category=Shell`** on this branch: no crash; the `VirtualView
cannot be null here` path is gone.
- On iOS 26.5,
`FlyoutHeaderLabelsAreArrangedWhenBoundTextChangesWithoutResizingHeader`
(#39877) failed 2/552. It is a layout assertion, and this PR doesn't
touch layout.
- The same `Category=Shell` run on an iPhone 11 Pro **iOS 18.5**
simulator (the device CI uses is iPhone 11 Pro, iOS 18.1) passed
552/552, XHarness exit 0.
- CI b828 also passed that test on iOS. So the iOS 26.5 failure is
local-environment only and unrelated to this revert.

### Re-landing #40056's fix

The BlazorWebView disposal leak from #40056 is still worth fixing. A
re-land needs to tolerate callbacks that arrive after
`Window.Destroying()`:
- the iOS modal wrapper's `ViewWillAppear`/dismissal;
- Android fragment transactions that are still pending;
- Windows window close.

It should also run `maui-pr-devicetests` (Controls: Modal, Shell,
General) on all platforms before merging. cc @Kebechet

### Issues Fixed

Relates to #40056 and #40116

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…nges (dotnet#39877)

<!-- 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!

### Issue Details
- In the Shell Flyout Header, the second Label bound to a ViewModel
property fails to calculate its correct height when its Text changes
from null to a long string at runtime, causing the text to appear empty,
get clipped, or fail to wrap properly.

### Root Cause
- PR dotnet#28713 introduced synchronous measurement during Shell flyout
header invalidation, which can occur before the label’s property mapper
updates its native text. This could cache stale measurements.
Reassigning an unchanged header frame also did not reliably schedule
layout, leaving child labels with empty or incorrect native frames.

### Description of Change
- Updated the InvalidateMeasure implementation in
ShellFlyoutHeaderContainer to call SetNeedsLayout() instead of
immediately recalculating and setting the frame, ensuring that native
view updates are properly handled before layout occurs.
- Modified LayoutSubviews in ShellFlyoutHeaderContainer to refresh child
measurements before arranging them, even if the header size remains
unchanged.

### Issues Fixed
Fixes dotnet#39739

### Validated the behaviour in the following platforms
- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac


### Output
| Platform | Before Fix | After Fix |
|----------|----------|----------|
| iOS | <video
src="https://github.com/user-attachments/assets/6921c32b-f9bc-43af-809c-3c230ff1602f">
| <video
src="https://github.com/user-attachments/assets/2755a524-3d38-4fe6-aff7-ac68e2e4dc9f">
|
| Mac | <video
src="https://github.com/user-attachments/assets/60c2f7f8-692b-423f-b843-2ddf8a348645">
| <video
src="https://github.com/user-attachments/assets/b53cb711-f28e-43cf-9283-a7dccd51ddc5">
|

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…ntrols device tests (dotnet#40486)

<!-- 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).

This is SR2 candidate integration work for dotnet#40116, so it targets
`candidate/11.0.1xx-sr2`. dotnet#40457 was merged straight into the candidate
(0eb47dd) and `net11` doesn't have it, so there is nothing to revert
on `net11`.

### Description of Change

This reverts dotnet#40457 ("Window: Disconnect page handlers when the window
is destroyed"), which crashes the Controls device-test apps on Android,
iOS and Windows and leaves MacCatalyst Controls device tests without
results.

dotnet#40457 changed `Window.Destroying()` to disconnect the handlers of the
window's page and modal stack. Platform callbacks still run after
`Destroying()`, and when they reach the now-disconnected handlers the
process crashes:

| Platform | Crash | Stack |
| --- | --- | --- |
| iOS (CoreCLR + Mono, iOS 18 and 26 queues),
Controls.DeviceTests-General | `InvalidOperationException: Page cannot
be null here` | `ControlsModalWrapper.UpdateBackgroundColor` ←
`ControlsModalWrapper.ViewWillAppear` (the modal is dismissed after
window teardown) |
| iOS (CoreCLR + Mono), Controls.DeviceTests-Shell |
`InvalidOperationException: VirtualView cannot be null here` |
`ShellPageRendererTracker.Dispose` ← `ShellSectionHandler.DisposePage` ←
`OnPopRequested` |
| Android (CoreCLR + Mono), API 33 | `ArgumentNullException` for
`context` | `ShellSectionRenderer.OnCreateView`. A pending fragment
transaction runs after teardown, and `FindMauiContext()` returns null. |
| Windows (packaged + unpackaged) | `0xc000027b`, faulting module
`Microsoft.UI.Xaml.dll` | Process crash during the Controls device tests
(attributed by mechanism; not reproduced locally) |
| MacCatalyst (CoreCLR, osx.15 + osx.26) | No test results | osx.15
`Controls Tests` ran into the 3600 s XHarness timeout (exit 94,
`TEST_RESULTS_MISSING`; the app was still alive). On osx.26 the app
exited after about 6 minutes with no results file, and XHarness still
reported success. Without dotnet#40457, both queues report 1636–1777 tests in
about 12 minutes (8 runs in builds 1690816, 1692066, 1692670, 1692736).
Attributed by correlation; not reproduced locally. |

**CI** (`maui-pr-devicetests` on the candidate branch):

| Build | Candidate head | Contains dotnet#40457 | Result |
| --- | --- | --- | --- |
|
[1692670](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1692670)
| b828f7b | no | Controls device tests passed |
|
[1692843](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1692843)
| e064224 | yes | Helix work items crash: iOS General + Shell on all
four iOS legs; Android CoreCLR + Mono; Windows packaged + unpackaged;
MacCatalyst `Controls Tests` produced no results on either queue |

The revert is a full `git revert` of 0eb47dd (5 files, +2/−214). It
restores `Window.cs` and removes the tests dotnet#40457 added:
- `BlazorWebViewTests.WindowDestroying.cs` and
`DisposalTrackingComponent.razor`;
- the `WindowsTests` and `ModalNavigationPlatformTests` unit tests for
the destroy-disconnect behavior.

These tests are removed together with the behavior they assert. No
unrelated test is changed.

dotnet#40457 merged without a `maui-pr-devicetests` run, so these crashes
first showed up after it landed on the candidate.

### Local evidence

Each run starts from candidate head a6d3ad9. The "re-apply" step
reverts the revert (`git revert --no-commit HEAD`), which gives back a
tree byte-identical to a6d3.

**iOS, `Category=Modal`** (CoreSimulator iPhone 16 Pro, iOS 26.5):

| Step | Result |
| --- | --- |
| a6d3 (with dotnet#40457) | RED: APP_CRASH, `Page cannot be null here` from
`ControlsModalWrapper.UpdateBackgroundColor` |
| This revert | GREEN: 222/222 passed |
| Re-apply dotnet#40457 | RED: same exception |
| Revert restored | GREEN: 222/222 passed |

**Android, `Category=Shell`** (emulator API 35, arm64):

| Step | Result |
| --- | --- |
| a6d3 (with dotnet#40457) | RED: APP_CRASH (XHarness exit 80), FATAL
`ArgumentNullException: context` at `ShellSectionRenderer.OnCreateView`,
right after `FlyoutContentUpdatesAfterChange` (identical to CI) |
| This revert | No crash |
| Re-apply dotnet#40457 | RED: same FATAL |
| Revert restored | GREEN: 197/197 passed, XHarness exit 0, no FATAL |

The first revert run had 4 `ShellRendererTransitionTests` failures
(193/197). They didn't come back when the revert was restored (197/197),
so they're intermittent and unrelated to this change.

**iOS, `Category=Shell`** on this branch: no crash; the `VirtualView
cannot be null here` path is gone.
- On iOS 26.5,
`FlyoutHeaderLabelsAreArrangedWhenBoundTextChangesWithoutResizingHeader`
(dotnet#39877) failed 2/552. It is a layout assertion, and this PR doesn't
touch layout.
- The same `Category=Shell` run on an iPhone 11 Pro **iOS 18.5**
simulator (the device CI uses is iPhone 11 Pro, iOS 18.1) passed
552/552, XHarness exit 0.
- CI b828 also passed that test on iOS. So the iOS 26.5 failure is
local-environment only and unrelated to this revert.

### Re-landing dotnet#40056's fix

The BlazorWebView disposal leak from dotnet#40056 is still worth fixing. A
re-land needs to tolerate callbacks that arrive after
`Window.Destroying()`:
- the iOS modal wrapper's `ViewWillAppear`/dismissal;
- Android fragment transactions that are still pending;
- Windows window close.

It should also run `maui-pr-devicetests` (Controls: Modal, Shell,
General) on all platforms before merging. cc @Kebechet

### Issues Fixed

Relates to dotnet#40056 and dotnet#40116

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 26, 2026
…hread

- Prefer the iPhone 11 Pro profile XHarness used while the selected
  runtime supports it. Shell flyout header geometry tests (#39877) fail on
  Dynamic Island phones; this keeps device coverage equivalent to Helix.
- WillTerminateDestroysMainPageWindowOnce (#40452) constructed the
  Application off the UI thread; native MTP test bodies run on the
  thread pool, so resolve it through InvokeOnMainThreadAsync.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 28, 2026
<!-- 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).

This is test infrastructure for the .NET 12 (`main`) line, so it targets
`main`.

### Description of Change

Migrate all repository test execution from **Helix + XHarness** to plain
**`dotnet test`** on **Microsoft.Testing.Platform (MTP)**.

This PR carries the migration from #39918 (by @mattleibow, commits
preserved) brought up to date with current `main` (.NET 12 SDK, `/review
run-device-tests`, recent product and test fixes), plus the follow-up
fixes needed to make it build and pass on .NET 12.

#### Why we need this

- **One way to run tests, everywhere.** Today unit tests run through
Arcade's Helix SDK (`eng/helix.proj`), device tests through Helix +
XHarness (`eng/helix_xharness.proj`), Appium tests through Cake, and
locally through yet other scripts. After this change the same command —
`dotnet test --project <test project>` (plus `--device` for mobile) —
runs every suite on a developer machine, in CI, and in the Copilot
review gate. A CI failure can be reproduced locally with the exact
command CI used.
- **Remove a fragile, opaque layer.** Helix/XHarness add payload
zipping, remote queues, a job monitor, custom work-item scripts and a
separate result path. Many recurring device-test infra failures
(XHarness exit 78/80/83 `APP_LAUNCH_FAILURE`/`APP_CRASH`, Helix jobs
never scheduled, stale or missing `testResults.xml`, queue/image drift
such as XHarness requiring an iPhone 11 Pro device type that iOS 27.1+
no longer ships) come from that layer, not from MAUI. Direct execution
on the agent gives real logs, real exit codes and the actual device in
the job.
- **Genuine, trustworthy results.** Every suite now produces the test
framework's own TRX via MTP (`--report-trx`), and empty selections or
missing reports fail the job instead of silently passing. On Android/iOS
the native app's own TRX is collected and reconciled with the host
proxy, so a crash cannot be reported as a pass.
- **Modern test stack.** xUnit v2 + VSTest + XHarness test runners are
replaced by **xUnit v3 + MTP**, which is what the .NET SDK `dotnet test`
and device (`--device`) support is built on. This unblocks newer xUnit
features (`TestContext`, cancellation, `Assert.Skip*`) and keeps us on
the path the SDK supports directly.
- **Fewer moving parts to maintain.** Removes `eng/helix.proj`,
`eng/helix_xharness.proj`, the Helix pipeline stages, the XHarness CLI
tool, and the XHarness/Helix package dependencies.

#### What changes

- **Unit tests**: all repository xUnit suites move to xUnit v3 (`4.0.2`)
on MTP (`2.5.1`); `global.json` selects `Microsoft.Testing.Platform` as
the `dotnet test` runner. CI (`stage-unit-tests.yml`) runs each project
with `dotnet test --project … --report-trx` on Windows and macOS (Debug
and Release) and validates the TRX
(`eng/scripts/Assert-TestResults.ps1`). Helix unit-test stages are
removed.
- **Device tests** (Controls, Core, Graphics, Essentials,
BlazorWebView): the XHarness/visual runners are replaced by native MTP
hosts — Android instrumentation, the normal Apple MAUI app/scene
lifecycle, and an owned Windows MSIX/unpackaged launcher.
`maui-pr-devicetests` runs them directly on device-capable agents
(`stage-device-tests.yml`, `device-tests-steps.yml`) with job-owned
emulators/simulators.
- **UI tests (Appium)** stay on NUnit, now hosted on MTP with matching
fixture-failure, retry and attachment handling.
- **Integration tests** run with `dotnet test`; legacy `--filter`
selectors are translated to MTP filters. iOS template apps are launched
with `simctl` on a dedicated simulator instead of XHarness.
- **Local tooling** (`Run-DeviceTests.ps1`, Cake, review-gate scripts,
skills/instructions) updated to the same direct commands.

#### Changes made while bringing #39918 onto current `main`

- Merged `main` (.NET 12 move #40060, `/review run-device-tests` #40545,
review-gate removal #40595, and other fixes) and resolved 23 conflicts.
- **`/review run-device-tests` selection ported** to the direct
template: `ci-device-tests.yml` passes
`selectedRun`/`selectedPlatforms`/`selectedProjects`/`selectedFilters`,
and `stage-device-tests.yml` runs only the selected platforms and
projects with the selected category skip-lists. Verified with the AzDO
YAML preview API (full run: 28 jobs; a sample selection of Android+iOS /
Controls+Essentials with `SkipCategories=Shell,Label`: exactly 4 jobs
with that filter). `eng/helix_xharness.proj` is no longer a trusted
dispatch path.
- **Device tests default to `net12.0` and CoreCLR only** — the .NET 12
mobile workloads no longer provide Mono (same as #40060).
- Took main's Switch hover-resource fix (#40209) over the PR's earlier
variant; kept the HybridWebView asset-ownership change together with
main's `DynamicDependency`.
- Ported main's UI-test retry recovery rules (#40407) into the shared
`UITestRetry.cs` used by Cake and MTP.
- Dropped the XHarness-only simulator runtime selection
(`SelectLatestIOSVersion`) and its tests; runtime/device-type selection
is covered by `SimulatorTests`.

#### Fixes found by running CI / locally after the merge

- **xUnit v3 adaptation of tests added on `main`**:
`TestContext.Current.CancellationToken` (xUnit1051), source-info
constructor for `WindowsFact` (xUnit3003); `UITest.NUnit.Tests` and the
Windows launcher build for the repo TFM instead of `net11.0`.
- **Async-void / inline continuation differences in xUnit v3** (v2's
`AsyncTestSyncContext` hid them):
- `ListProxyTests.SynchronizedCollectionAdd` leaked thread-static
dispatcher options onto a thread-pool thread, so later tests got a
dispatcher that always required dispatch (68 Storyboard failures in
macOS Release). Restored after use; fixtures reset the options.
- Shell tests resumed inline from `Navigated`, so the *next* tests ran
inside Shell's navigation callback and had their implicit routes reset
(`DeferPopNavigation(Pop)`). Verified locally by detecting
`FireNavigatedEvents` on the next test's stack before/after the change.
- **Native runner thread affinity** (test bodies run on the thread pool,
not the UI thread as under XHarness):
`WillTerminateDestroysMainPageWindowOnce` resolved the `Application` off
the UI thread; the CarouselView leak test posted a UIKit notification
off the UI thread.
- **iOS simulator selection**: only use device types that the runtime
lists (device-specific iOS 27.1 builds only accept one, causing
`SimError 403 Incompatible device`), and prefer the iPhone 11 Pro
profile XHarness used (Shell flyout header geometry tests from #39877
fail on Dynamic Island phones; passes on iPhone 11 Pro, fails on iPhone
16 — reproduced locally).
- **Mac Catalyst**: `dotnet test` starts the app executable directly, so
unlike `open`/XHarness it isn't activated; activate it before running
(animated CarouselView scrolls intermittently never finished).
- **Integration tests**: shut down build servers after installing the
test workloads — reused MSBuild nodes kept a stale workload resolver and
nested `UseWorkload=true` sample builds failed with NU1015 (reproduced
locally; Samples macOS now passes in CI). The Android `maui-blazor` +
`TrimMode=full` row is skipped explicitly: the previous runner silently
dropped `TrimMode`, and Blazor does not support full trimming
(dotnet/aspnetcore#63951).
- **Windows `HybridWebView` disconnect** NRE when `CoreWebView2` is not
(or no longer) initialized — exposed by the new fixture teardown that
disconnects every handler.
- Docs spellcheck word, and a template boolean comparison so the device
stage doesn't expand to zero jobs.
- **UI-test retry reconciliation**: when a fixture's `OneTimeSetUp`
fails, NUnit reports its `[Ignore]`d tests as failed and the retry
reports them skipped. MTP's TRX names classes of fixtures with arguments
(every UI-test fixture, e.g. `EditorFeatureTests(Windows)`) by namespace
only, so the ignored tests were never matched as recovered and the job
failed although the retry passed. Replaying the real CI TRX/NUnit
reports reproduces the failure before the fix and merges cleanly after
it; `FixtureRecoveryReconcilesIgnoredTestsInParameterizedFixtures`
covers it.
- **iOS CarouselView test timing** (`Animated ScrollTo Does Not Report
Positions It Passes Over`, failed on every native CI run, passed under
Helix): with logging, every failing run showed a still-queued
initial-position pass scrolling back to page 0 without animation,
cancelling the test's animated `ScrollTo`. Under the native runner the
test can resume between those queued passes. The test now lets them
drain; full-class cold runs went from 2/9 failing to 5/5 passing, and it
passes in CI.
- **`main` build breaks from re-enabled CA1416** (#40663): carried the
fixes from #40708 (merged) and #40720
(`UISettings.AnimationsEnabledChanged` in `PlatformTicker` and
`MotionPolicy` requires Windows 10.0.19041). The Windows errors only
surfaced one project at a time because `Core` references `Essentials`.

### Validation

Local (macOS arm64, .NET SDK `12.0.100-alpha.1.26523.103`, Debug,
`dotnet test --project <csproj> --report-trx`):

| Project | Result |
| --- | --- |
| Controls.Xaml.UnitTests | 2,327 passed, 8 skipped |
| Controls.Core.UnitTests | 7,453 passed, 30 skipped |
| Controls.BindingSourceGen.UnitTests | 135 passed |
| SourceGen.UnitTests | 997 passed |
| Core.UnitTests | 1,147 passed |
| Resizetizer.UnitTests | 795 passed, 3 skipped |
| Essentials.UnitTests | 520 passed |
| Essentials.ExternalBackend.UnitTests | 6 passed |
| Graphics.Tests | 406 passed |
| VisualTestUtils.MagickNet.Tests | 13 passed |
| MauiBlazorWebView.UnitTests | 70 passed |
| MauiBlazorWebView.ExternalHandler.UnitTests | 52 passed |
| UITest.NUnit.Tests | 50 passed, 5 skipped |
| TestUtils.UnitTests | 61 passed, 1 skipped |

Pester (pipeline/runner scripts): `Direct-TestDevice`, `Cake-Mtp`,
`RunTests`, `NUnitMtp`, `XunitMtp`, `Run-DeviceTests`,
`WindowsTestPackage`, `Assert-TestResults`, `CopilotPipeline`,
`Review-PR`, `Verify-TestsFail`, `BuildAndRunHostApp`, `Review-Tests`,
`Recover-MissedReviewCommands`: 600+ passed. The only remaining failure
(`handles qualified selections in every stage guard`, expects 10 vs 11)
also fails on `main` and is unrelated.

Note:
`StoryboardTests.StoppingFromPropertyChangingDuringATakeoverRaisesOnePairOfNotifications`
(added on `main`) is culture-sensitive and fails under a comma-decimal
locale on `main` as well; it passes under `en-US` as in CI.

#### CI

Every pipeline was run with `/azp run` on this PR and on validation-only
drafts:
- #40703: this PR's changes on `net11`.
- #40705: the #40703 changes plus sample PRs #40696, #40660, #40654 and
#40691, to check that tests added by other PRs run under the native
runners.
- #40706: this PR plus sample PR #40669.

Failures were compared against `main`/`net11` Helix baselines by test
name.

| Pipeline | This PR (`main`) | `net11` validation (#40703 / #40705) |
| --- | --- | --- |
| `maui-pr` (build, pack, unit tests, integration) | ✅ 35/35 jobs (with
the CA1416 fixes) | ✅ 33/33 jobs |
| `maui-pr-devicetests` | ✅ Android, iOS, Mac Catalyst except
`PageTransitions` tests that fail identically in `main`'s Helix runs | ✅
Android, iOS, Mac Catalyst; only intermittent single-test failures that
don't repeat across runs |
| `maui-pr-uitests` (Appium on MTP) | ✅ 133/134 jobs; the only failure,
WinUI `SharedElementLandsAndSourceIsRestoredAfterPop`, also fails on
`main`'s Helix runs | ✅ 130/133; see below |

Remaining UI-test failures on `net11`, none of them regressions:
- `DragAndDropWithAnElementThatIsRemoved` (Mac Catalyst) fails in 2 of
the last 10 `net11` Helix runs too.
- The RefreshView tests failed only on #40705, which includes
RefreshView sample PR #40660.
- The `vlatest` shard failed because the agent couldn't download the iOS
18.5 simulator runtime.
- Material3 (API 36) screenshots in the last two runs came out 87 px
taller. #40603, merged on `net11` yesterday, now crops by the status-bar
height that Appium reports. The same tree and emulator setup passed
430/433 in the two previous runs.

**Known remaining device-test blockers (from #39918, not regressions of
this merge):** packaged Windows MSIX installation is rejected with
`0x800B0109` (the temporary signer is not a trusted root on the agent
image — needs owner-provided signing/provisioning), and the Windows
Controls unpackaged suite can terminate with `0xDEAD` after ~350 tests
(native composition resource exhaustion investigated in #39918).

### Issues Fixed

No product issue. Supersedes/continues #39918.

---------

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 28, 2026
…[net11]

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

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

This is test infrastructure for the .NET 12 (`main`) line, so it targets
`main`.

Migrate all repository test execution from **Helix + XHarness** to plain
**`dotnet test`** on **Microsoft.Testing.Platform (MTP)**.

This PR carries the migration from #39918 (by @mattleibow, commits
preserved) brought up to date with current `main` (.NET 12 SDK, `/review
run-device-tests`, recent product and test fixes), plus the follow-up
fixes needed to make it build and pass on .NET 12.

- **One way to run tests, everywhere.** Today unit tests run through
Arcade's Helix SDK (`eng/helix.proj`), device tests through Helix +
XHarness (`eng/helix_xharness.proj`), Appium tests through Cake, and
locally through yet other scripts. After this change the same command —
`dotnet test --project <test project>` (plus `--device` for mobile) —
runs every suite on a developer machine, in CI, and in the Copilot
review gate. A CI failure can be reproduced locally with the exact
command CI used.
- **Remove a fragile, opaque layer.** Helix/XHarness add payload
zipping, remote queues, a job monitor, custom work-item scripts and a
separate result path. Many recurring device-test infra failures
(XHarness exit 78/80/83 `APP_LAUNCH_FAILURE`/`APP_CRASH`, Helix jobs
never scheduled, stale or missing `testResults.xml`, queue/image drift
such as XHarness requiring an iPhone 11 Pro device type that iOS 27.1+
no longer ships) come from that layer, not from MAUI. Direct execution
on the agent gives real logs, real exit codes and the actual device in
the job.
- **Genuine, trustworthy results.** Every suite now produces the test
framework's own TRX via MTP (`--report-trx`), and empty selections or
missing reports fail the job instead of silently passing. On Android/iOS
the native app's own TRX is collected and reconciled with the host
proxy, so a crash cannot be reported as a pass.
- **Modern test stack.** xUnit v2 + VSTest + XHarness test runners are
replaced by **xUnit v3 + MTP**, which is what the .NET SDK `dotnet test`
and device (`--device`) support is built on. This unblocks newer xUnit
features (`TestContext`, cancellation, `Assert.Skip*`) and keeps us on
the path the SDK supports directly.
- **Fewer moving parts to maintain.** Removes `eng/helix.proj`,
`eng/helix_xharness.proj`, the Helix pipeline stages, the XHarness CLI
tool, and the XHarness/Helix package dependencies.

- **Unit tests**: all repository xUnit suites move to xUnit v3 (`4.0.2`)
on MTP (`2.5.1`); `global.json` selects `Microsoft.Testing.Platform` as
the `dotnet test` runner. CI (`stage-unit-tests.yml`) runs each project
with `dotnet test --project … --report-trx` on Windows and macOS (Debug
and Release) and validates the TRX
(`eng/scripts/Assert-TestResults.ps1`). Helix unit-test stages are
removed.
- **Device tests** (Controls, Core, Graphics, Essentials,
BlazorWebView): the XHarness/visual runners are replaced by native MTP
hosts — Android instrumentation, the normal Apple MAUI app/scene
lifecycle, and an owned Windows MSIX/unpackaged launcher.
`maui-pr-devicetests` runs them directly on device-capable agents
(`stage-device-tests.yml`, `device-tests-steps.yml`) with job-owned
emulators/simulators.
- **UI tests (Appium)** stay on NUnit, now hosted on MTP with matching
fixture-failure, retry and attachment handling.
- **Integration tests** run with `dotnet test`; legacy `--filter`
selectors are translated to MTP filters. iOS template apps are launched
with `simctl` on a dedicated simulator instead of XHarness.
- **Local tooling** (`Run-DeviceTests.ps1`, Cake, review-gate scripts,
skills/instructions) updated to the same direct commands.

- Merged `main` (.NET 12 move #40060, `/review run-device-tests` #40545,
review-gate removal #40595, and other fixes) and resolved 23 conflicts.
- **`/review run-device-tests` selection ported** to the direct
template: `ci-device-tests.yml` passes
`selectedRun`/`selectedPlatforms`/`selectedProjects`/`selectedFilters`,
and `stage-device-tests.yml` runs only the selected platforms and
projects with the selected category skip-lists. Verified with the AzDO
YAML preview API (full run: 28 jobs; a sample selection of Android+iOS /
Controls+Essentials with `SkipCategories=Shell,Label`: exactly 4 jobs
with that filter). `eng/helix_xharness.proj` is no longer a trusted
dispatch path.
- **Device tests default to `net12.0` and CoreCLR only** — the .NET 12
mobile workloads no longer provide Mono (same as #40060).
- Took main's Switch hover-resource fix (#40209) over the PR's earlier
variant; kept the HybridWebView asset-ownership change together with
main's `DynamicDependency`.
- Ported main's UI-test retry recovery rules (#40407) into the shared
`UITestRetry.cs` used by Cake and MTP.
- Dropped the XHarness-only simulator runtime selection
(`SelectLatestIOSVersion`) and its tests; runtime/device-type selection
is covered by `SimulatorTests`.

- **xUnit v3 adaptation of tests added on `main`**:
`TestContext.Current.CancellationToken` (xUnit1051), source-info
constructor for `WindowsFact` (xUnit3003); `UITest.NUnit.Tests` and the
Windows launcher build for the repo TFM instead of `net11.0`.
- **Async-void / inline continuation differences in xUnit v3** (v2's
`AsyncTestSyncContext` hid them):
- `ListProxyTests.SynchronizedCollectionAdd` leaked thread-static
dispatcher options onto a thread-pool thread, so later tests got a
dispatcher that always required dispatch (68 Storyboard failures in
macOS Release). Restored after use; fixtures reset the options.
- Shell tests resumed inline from `Navigated`, so the *next* tests ran
inside Shell's navigation callback and had their implicit routes reset
(`DeferPopNavigation(Pop)`). Verified locally by detecting
`FireNavigatedEvents` on the next test's stack before/after the change.
- **Native runner thread affinity** (test bodies run on the thread pool,
not the UI thread as under XHarness):
`WillTerminateDestroysMainPageWindowOnce` resolved the `Application` off
the UI thread; the CarouselView leak test posted a UIKit notification
off the UI thread.
- **iOS simulator selection**: only use device types that the runtime
lists (device-specific iOS 27.1 builds only accept one, causing
`SimError 403 Incompatible device`), and prefer the iPhone 11 Pro
profile XHarness used (Shell flyout header geometry tests from #39877
fail on Dynamic Island phones; passes on iPhone 11 Pro, fails on iPhone
16 — reproduced locally).
- **Mac Catalyst**: `dotnet test` starts the app executable directly, so
unlike `open`/XHarness it isn't activated; activate it before running
(animated CarouselView scrolls intermittently never finished).
- **Integration tests**: shut down build servers after installing the
test workloads — reused MSBuild nodes kept a stale workload resolver and
nested `UseWorkload=true` sample builds failed with NU1015 (reproduced
locally; Samples macOS now passes in CI). The Android `maui-blazor` +
`TrimMode=full` row is skipped explicitly: the previous runner silently
dropped `TrimMode`, and Blazor does not support full trimming
(dotnet/aspnetcore#63951).
- **Windows `HybridWebView` disconnect** NRE when `CoreWebView2` is not
(or no longer) initialized — exposed by the new fixture teardown that
disconnects every handler.
- Docs spellcheck word, and a template boolean comparison so the device
stage doesn't expand to zero jobs.
- **UI-test retry reconciliation**: when a fixture's `OneTimeSetUp`
fails, NUnit reports its `[Ignore]`d tests as failed and the retry
reports them skipped. MTP's TRX names classes of fixtures with arguments
(every UI-test fixture, e.g. `EditorFeatureTests(Windows)`) by namespace
only, so the ignored tests were never matched as recovered and the job
failed although the retry passed. Replaying the real CI TRX/NUnit
reports reproduces the failure before the fix and merges cleanly after
it; `FixtureRecoveryReconcilesIgnoredTestsInParameterizedFixtures`
covers it.
- **iOS CarouselView test timing** (`Animated ScrollTo Does Not Report
Positions It Passes Over`, failed on every native CI run, passed under
Helix): with logging, every failing run showed a still-queued
initial-position pass scrolling back to page 0 without animation,
cancelling the test's animated `ScrollTo`. Under the native runner the
test can resume between those queued passes. The test now lets them
drain; full-class cold runs went from 2/9 failing to 5/5 passing, and it
passes in CI.
- **`main` build breaks from re-enabled CA1416** (#40663): carried the
fixes from #40708 (merged) and #40720
(`UISettings.AnimationsEnabledChanged` in `PlatformTicker` and
`MotionPolicy` requires Windows 10.0.19041). The Windows errors only
surfaced one project at a time because `Core` references `Essentials`.

Local (macOS arm64, .NET SDK `12.0.100-alpha.1.26523.103`, Debug,
`dotnet test --project <csproj> --report-trx`):

| Project | Result |
| --- | --- |
| Controls.Xaml.UnitTests | 2,327 passed, 8 skipped |
| Controls.Core.UnitTests | 7,453 passed, 30 skipped |
| Controls.BindingSourceGen.UnitTests | 135 passed |
| SourceGen.UnitTests | 997 passed |
| Core.UnitTests | 1,147 passed |
| Resizetizer.UnitTests | 795 passed, 3 skipped |
| Essentials.UnitTests | 520 passed |
| Essentials.ExternalBackend.UnitTests | 6 passed |
| Graphics.Tests | 406 passed |
| VisualTestUtils.MagickNet.Tests | 13 passed |
| MauiBlazorWebView.UnitTests | 70 passed |
| MauiBlazorWebView.ExternalHandler.UnitTests | 52 passed |
| UITest.NUnit.Tests | 50 passed, 5 skipped |
| TestUtils.UnitTests | 61 passed, 1 skipped |

Pester (pipeline/runner scripts): `Direct-TestDevice`, `Cake-Mtp`,
`RunTests`, `NUnitMtp`, `XunitMtp`, `Run-DeviceTests`,
`WindowsTestPackage`, `Assert-TestResults`, `CopilotPipeline`,
`Review-PR`, `Verify-TestsFail`, `BuildAndRunHostApp`, `Review-Tests`,
`Recover-MissedReviewCommands`: 600+ passed. The only remaining failure
(`handles qualified selections in every stage guard`, expects 10 vs 11)
also fails on `main` and is unrelated.

Note:
`StoryboardTests.StoppingFromPropertyChangingDuringATakeoverRaisesOnePairOfNotifications`
(added on `main`) is culture-sensitive and fails under a comma-decimal
locale on `main` as well; it passes under `en-US` as in CI.

Every pipeline was run with `/azp run` on this PR and on validation-only
drafts:
- #40703: this PR's changes on `net11`.
- #40705: the #40703 changes plus sample PRs #40696, #40660, #40654 and
runners.
- #40706: this PR plus sample PR #40669.

Failures were compared against `main`/`net11` Helix baselines by test
name.

| Pipeline | This PR (`main`) | `net11` validation (#40703 / #40705) |
| --- | --- | --- |
| `maui-pr` (build, pack, unit tests, integration) | ✅ 35/35 jobs (with
the CA1416 fixes) | ✅ 33/33 jobs |
| `maui-pr-devicetests` | ✅ Android, iOS, Mac Catalyst except
`PageTransitions` tests that fail identically in `main`'s Helix runs | ✅
Android, iOS, Mac Catalyst; only intermittent single-test failures that
don't repeat across runs |
| `maui-pr-uitests` (Appium on MTP) | ✅ 133/134 jobs; the only failure,
WinUI `SharedElementLandsAndSourceIsRestoredAfterPop`, also fails on
`main`'s Helix runs | ✅ 130/133; see below |

Remaining UI-test failures on `net11`, none of them regressions:
- `DragAndDropWithAnElementThatIsRemoved` (Mac Catalyst) fails in 2 of
the last 10 `net11` Helix runs too.
- The RefreshView tests failed only on #40705, which includes
RefreshView sample PR #40660.
- The `vlatest` shard failed because the agent couldn't download the iOS
18.5 simulator runtime.
- Material3 (API 36) screenshots in the last two runs came out 87 px
taller. #40603, merged on `net11` yesterday, now crops by the status-bar
height that Appium reports. The same tree and emulator setup passed
430/433 in the two previous runs.

**Known remaining device-test blockers (from #39918, not regressions of
this merge):** packaged Windows MSIX installation is rejected with
`0x800B0109` (the temporary signer is not a trusted root on the agent
image — needs owner-provided signing/provisioning), and the Windows
Controls unpackaged suite can terminate with `0xDEAD` after ~350 tests
(native composition resource exhaustion investigated in #39918).

No product issue. Supersedes/continues #39918.

---------

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit b5108cd)

net11 adaptation: net11.0 TFM, CoreCLR + Mono device-test runtimes and net11's Arcade SDK version, matching validation PR #40703. SourceGen tests for .NET 12-only features are not brought over.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration shell-flyout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Labels in Shell Flyout have zero height after backing properties are updated from null to non-empty string

6 participants