Skip to content

[release/10.0.1xx-sr14] .NET 10 SR14 (10.0.140) - #40222

Draft
kubaflo wants to merge 6 commits into
release/10.0.1xx-sr13from
release/10.0.1xx-sr14
Draft

kubaflo wants to merge 6 commits into
release/10.0.1xx-sr13from
release/10.0.1xx-sr14

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Note

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

Description of Change

Draft tracking PR for .NET MAUI 10 SR14 (10.0.140): release/10.0.1xx-sr14 → release/10.0.1xx-sr13.

main, net11 and the inflight lanes are now .NET 11, so the .NET 10 SR14 line was cut from the SR13 release head (54d76458e0). .NET 10 fixes for SR14 should target release/10.0.1xx-sr14; this PR shows the accumulated SR14 delta over SR13.

Content:

Keep in draft. This PR does not tag, publish, or authorize a release; the internal dnceng mirror of release/10.0.1xx-sr14 has not been created.

Issues Fixed

N/A – SR14 release tracking; individual fixes are linked in their PRs.

…on backports (#40217)

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

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

**Explicit release-target exception:** this PR intentionally targets the
new `release/10.0.1xx-sr14` branch. `main`, `net11` and the inflight
lanes are now .NET 11, so .NET 10 SR14 is cut from the SR13 release head
(`release/10.0.1xx-sr14` was created at `54d76458e0`, the tip of
`release/10.0.1xx-sr13`, which already includes all post-cut SR13 fixes
#39830, #39855, #39879, #39891 and the servicing/stable configuration
from #39774).

This PR brings the .NET 10 changes needed since SR13:

1. **Backport #39887** – `[Windows] Prevent duplicate Shell startup
navigation from stale tab selection events`. Fixes #39859 (regressed in
10.0.120); it was merged only to `main`. Clean `cherry-pick -x`.
2. **Backport #40132** – `Fix custom Shape.PathForBounds dispatch
regression`. Fixes #40129 (regressed in 10.0.130); it was merged only to
`candidate/11.0.1xx-sr2`. The unrelated .NET 11
`eng/release-rollover.json` change from that commit is excluded (file
does not exist on the .NET 10 line).
3. **Version bump** – `PatchVersion` 130 → 140 in `eng/Versions.props`.
Servicing label and `StabilizePackageVersion=true` are inherited from
SR13.

Reviewed and intentionally **not** included:

- #40136 (`net10.0` Publish-Build-Assets cleanup): SR13 has no
`Publish-Build-Assets` references, so nothing to remove.
- #39882 (re-land of the CollectionView2 height fix): SR13 already
carries the revert #39855 that fixed #39847; re-landing is a
fix-forward, not a regression fix.
- #40213 (`[net10.0][XSG]` CA2252 suppression, issue #40045): still
open/unmerged; can be backported once approved.
- Other `regressed-in-10.0.1x0` issues closed since the SR13 cut
(#38622, #39557/#39681, #39722) are already fixed on SR13 or were fixed
outside MAUI.

Keep in draft pending review and CI. This PR does not tag, publish, or
authorize a release; the internal dnceng mirror of
`release/10.0.1xx-sr14` has not been created.

#### Validation

Using the pinned SDK `10.0.113` provisioned by `eng/common/dotnet.sh`:

- `dotnet msbuild eng/Versions.props
-getProperty:PatchVersion,SdkBandVersion,PreReleaseVersionLabel,StabilizePackageVersion,DotNetFinalVersionKind`
→ `140`, `10.0.100`, `servicing`, `true`, `release`. `xmllint --noout
eng/Versions.props` passed.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -f
net10.0 --filter FullyQualifiedName~StrokeShapeTests` (platform TFMs
disabled): **passed 59/59**. With `Shape.cs` reverted to SR13: **failed
3/59** (the new `CustomShapeReimplementingIShape*` tests); restored:
**passed 59/59**.
- #39887 is Windows-only (`ShellItemHandler.Windows.cs` + Windows device
test) and was not built locally on macOS; it relies on CI.

### Issues Fixed

Fixes #39859
Fixes #40129

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 13, 2026 13:00 — with GitHub Actions Inactive
@github-actions

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

This comment has been minimized.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Nov 13, 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 b474cdf.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

…tion attribute (#40213)

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

### Description of Change

On MAUI 10.0.x, when `MauiAllowImplicitXmlnsDeclaration` is defined, the
XAML source generator emits `[assembly: AllowImplicitXmlnsDeclaration]`
into `GlobalXmlns.g.cs`. That attribute is marked
`[RequiresPreviewFeatures]`.

CA2252 is suppressed only if the app assembly carries `[assembly:
RequiresPreviewFeatures]`. The SDK adds that attribute only when
`EnablePreviewFeatures=true` **and** the project targets the SDK's
latest TFM (`IsNetCoreAppTargetingLatestTFM`). A `net10.0` app built
with the .NET 11 SDK therefore fails with `GlobalXmlns.g.cs(15,12):
error CA2252`. Visual Studio picked a .NET 10 SDK, which is why the
build passed there and failed from the CLI.

Defining `MauiAllowImplicitXmlnsDeclaration` is already the explicit
opt-in, and the runtime, XamlC and SourceGen paths only check that the
attribute is present. So the generator now wraps the emitted attribute
in `#pragma warning disable/restore CA2252`. The public attribute is
unchanged; user code that applies it by hand still gets CA2252 as
before.

**Tests:** `Maui40045Tests` runs `XamlGenerator` with the
`MauiAllowImplicitXmlnsDeclaration` symbol on a compilation that has no
`[assembly: RequiresPreviewFeatures]`, then runs the real CA2252
analyzer from `Microsoft.CodeAnalysis.NetAnalyzers` over the result. The
analyzer path comes from the project's resolved `@(Analyzer)` items.

**Validation:**
- `dotnet test
src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj
--filter FullyQualifiedName~Maui40045`: passes with the fix. It fails
without the fix with `GlobalXmlns.g.cs(15,12): error CA2252`.
- `dotnet test
src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj`: 180
passed, 0 failed.
- End-to-end: a `net10.0` project on the .NET 11 RC2 SDK with
`Microsoft.Maui.Controls` 10.0.130, the define and
`EnablePreviewFeatures=true` fails with CA2252. With the patched
`Microsoft.Maui.Controls.SourceGen.dll` swapped in, it builds.

**.NET 11 / main:** no change needed. The generator no longer emits the
attribute (#33834), and the attribute is `[Obsolete]` instead of
preview-gated. `Microsoft.Maui.Controls` 11.0.10 builds cleanly with the
same settings on both `net11.0` (with
`GenerateRequiresPreviewFeaturesAttribute=false`) and `net10.0`.

### Issues Fixed

Fixes #40045

---------
@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 13, 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 — 1 finding

Reviewed commit 72615b7.

See inline comments for details.

<!-- Used by Maui40045Tests to run the CA2252 analyzer over generated code -->
<Target Name="_AddNetAnalyzersPathMetadata" BeforeTargets="GetAssemblyAttributes" DependsOnTargets="ResolveLockFileAnalyzers">
<ItemGroup>
<AssemblyMetadata Include="NetAnalyzersPath" Value="%(Analyzer.FullPath)" Condition="'%(Analyzer.Filename)' == 'Microsoft.CodeAnalysis.NetAnalyzers'" />

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.

[moderate] Build & MSBuild - This embeds the build machine's absolute analyzer path into the test assembly. eng/helix.proj includes this project in unit-test payloads sent to Windows and macOS workers, where the original SDK/NuGet path is unavailable. Maui40045Tests.GetPreviewFeaturesAnalyzers passes that embedded path directly to AnalyzerFileReference, so the new test fails while loading the analyzer instead of checking CA2252. The correlation payloads do not remap that path. Copy the required analyzer assemblies into the test payload and resolve them relative to the test assembly.

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

This comment has been minimized.

@github-actions

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

…0339)

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

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

Backport of #40199 to `release/10.0.1xx-sr14` (SR14 / 10.0.140, tracking
PR #40222), as requested in
#40199 (comment).

`WeakCommandSubscription.CommandCanExecuteSubscription` now keeps a
`WeakReference<BindableObject>` to the target and resolves it before
invoking the handler. A `DependentHandle` can still expose a
finalization-reachable target after its binding weak references have
been finalized; notifying that target caused the crash. When the target
is gone, the subscription disposes itself. Cost: one weak reference per
subscription.

Clean cherry-pick of 0088a35 (no
conflicts).

Validation on the SR14 base (72615b7) with SDK
10.0.113-servicing.26454.107 (from `global.json`), `net10.0`, mobile
TFMs disabled:
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj
--filter
"FullyQualifiedName~CommandTests|FullyQualifiedName~WeakCommand"` →
passed 48/48
- `CanExecuteDoesNotRefreshCollectedButtonBindings` with production
change reverted → failed 3/3; restored → passed 3/3
- Full `Controls.Core.UnitTests` → passed 5966, skipped 30, failed 0

Not run: customer-app validation and Android/iOS runtime validation.

### Issues Fixed

Fixes #40198

Co-authored-by: Timothy Sturm <timothysturm@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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 17, 2026
@MauiBot

MauiBot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification for commit 23c83479.

Result PASSED Platform Android Commit 23c83479


🧪 Gate analysis — click to expand

✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence.

🧪 Unit tests
Test group Without fix With fix
CommandTests ✅ Failed as expected (104s) ✅ Passed (107s)
Maui40045Tests ⚠ Build blocked ✅ Passed (25s)
StrokeShapeTests ✅ Failed as expected (18s) ✅ Passed (16s)
Execution log excerpts

Without fix CommandTests

     at System.WeakReference`1.SetTarget(T target)
   at Microsoft.Maui.Controls.Internals.TypedBinding`2.ApplyToResolvedSource(Object source, BindableObject target, BindableProperty targetProperty, Boolean fromBindingContextChanged, SetterSpecificity specificity) in /_/src/Controls/src/Core/TypedBinding.cs:line 257
   at Microsoft.Maui.Controls.Internals.TypedBinding`2.Apply(Object context, BindableObject bindObj, BindableProperty targetProperty, Boolean fromBindingContextChanged, SetterSpecificity specificity) in /_/src/Controls/src/Core/TypedBinding.cs:line 204
   at Microsoft.Maui.Controls.BindableObject.ForceBindingApply(BindableProperty targetProperty) in /_/src/Controls/src/Core/BindableObject.cs:line 457
   at Microsoft.Maui.Controls.CommandElement.GetCanExecute(ICommandElement commandElement, BindableProperty commandProperty) in /_/src/Controls/src/Core/CommandElement.cs:line 64
   at Microsoft.Maui.Controls.Button.get_IsEnabledCore() in /_/src/Controls/src/Core/Button/Button.cs:line 468
   at Microsoft.Maui.Controls.VisualElement.CoerceIsEnabledProperty(BindableObject bindable, Object value) in /_/src/Controls/src/Core/VisualElement/VisualElement.cs:line 1772
   at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity) in /_/src/Controls/src/Core/BindableObject.cs:line 607
   at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, SetterSpecificity specificity) in /_/src/Controls/src/Core/BindableObject.cs:line 559
   at Microsoft.Maui.Controls.BindableObjectExtensions.RefreshPropertyValue(BindableObject self, BindableProperty property, Object value) in /_/src/Controls/src/Core/BindableObjectExtensions.cs:line 28
   at Microsoft.Maui.Controls.VisualElement.RefreshIsEnabledProperty() in /_/src/Controls/src/Core/VisualElement/VisualElement.cs:line 1897
   at Microsoft.Maui.Controls.Button.M

With fix CommandTests

cCanExecute(expected: False) [< 1 ms]
  Passed CanExecuteDoesNotRefreshCollectedButtonBindings [28 ms]
  Passed ThrowsWithNullConstructor [< 1 ms]
  Passed ExecuteDoesNotRunIfParameterIsWrongValueType [< 1 ms]
  Passed GenericThrowsWithNullExecuteAndCanExecuteValid [< 1 ms]
  Passed ThrowsWithNullExecuteValidCanExecute [< 1 ms]
  Passed CanExecuteUsesParameterIfReferenceTypeAndSetToNull [< 1 ms]
  Passed ChangeCanExecute [< 1 ms]
  Passed GenericExecute [< 1 ms]
  Passed ThrowsWithNullCanExecute [< 1 ms]
  Passed ThrowsWithNullParameterizedConstructor [< 1 ms]
  Passed CanExecuteUsesParameterIfNullableAndSetToNull [< 1 ms]
  Passed ExecuteDoesNotRunIfValueTypeAndSetToNull [< 1 ms]
  Passed Constructor [< 1 ms]
  Passed ThrowsWithNullParameterizedCanExecute [< 1 ms]
  Passed ExecuteRunsIfNullableAndSetToNull [< 1 ms]
  Passed ExecuteParameterized [3 ms]
[xUnit.net 00:00:03.15]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed GenericThrowsWithValidExecuteAndCanExecuteNull [< 1 ms]
  Passed ExecuteWithCanExecute [< 1 ms]
  Passed CanExecuteReturnsFalseIfParameterIsWrongReferenceType [< 1 ms]
Test Run Successful.
Total tests: 48
     Passed: 48
 Total time: 3.7243 Seconds

Without fix Maui40045Tests

[xUnit.net 00:00:02.84]       Collection: [Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/GlobalXmlns.g.cs(15,12): error CA2252: Using 'AllowImplicitXmlnsDeclarationAttribute' requires opting into preview features. See https://aka.ms/dotnet-warnings/preview-features for more information.]
Collection: [Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/GlobalXmlns.g.cs(15,12): error CA2252: Using 'AllowImplicitXmlnsDeclarationAttribute' requires opting into preview features. See https://aka.ms/dotnet-warnings/preview-features for more information.]
     at Microsoft.Maui.Controls.Xaml.UnitTests.SourceGen.Maui40045Tests.ImplicitXmlnsOptInDoesNotRequirePreviewFeaturesAssemblyAttribute() in /_/src/Controls/tests/SourceGen.UnitTests/Maui40045Tests.cs:line 34

With fix Maui40045Tests

 Restored /home/vsts/work/1/s/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj (in 736 ms).
  Restored /home/vsts/work/1/s/src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj (in 91 ms).
  6 of 9 projects are up-to-date for restore.
Test run for /home/vsts/work/1/s/artifacts/bin/SourceGen.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.SourceGen.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.2 (x64)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.13)
[xUnit.net 00:00:00.12]   Discovering: Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:00.27]   Discovered:  Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:00.28]   Starting:    Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:02.70]   Finished:    Microsoft.Maui.Controls.SourceGen.UnitTests
  Passed Microsoft.Maui.Controls.Xaml.UnitTests.SourceGen.Maui40045Tests.ImplicitXmlnsOptInDoesNotRequirePreviewFeaturesAssemblyAttribute [2 s]
Test Run Successful.
Total tests: 1
     Passed: 1
 Total time: 3.4212 Seconds

PR head: 23c83479.

Without-fix baseline: 54d76458.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 17, 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 — 1 finding

Reviewed commit 23c8347.

Previously reported findings were not duplicated.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@kubaflo — test-failure analysis for commit 23c8347.

Scope CI failures Commit 23c8347


🧪 CI Analysis — click to expand
📊 maui-pr
  • 🔴 Likely PR-caused — Maui40045 analyzer loading: four Windows/macOS Debug/Release failures plus four SourceGen BadExit results; new metadata embeds a build-machine analyzer path unavailable on Helix.
  • 🟡 Needs human investigation — RunOniOS_MauiReleaseTrimFull, ARM64: launch failed; inspect launch output. Target NativeAOT failures are not equivalent full-trim evidence.

🧪 maui-pr-devicetests

No failures found.


🧪 maui-pr-uitests

🧭 Follow-up — actions and refresh

Next action: Make analyzer assets portable; compare unresolved cases using identical base/head setups and restore missing diagnostics.

Maintainers: comment /review tests to refresh this report.

…ow in WillTerminate (#40554)

Backport of #40452 to .NET 10 servicing. Fixes #40438 for .NET 10.

The iOS 27 SDK makes the UIScene lifecycle mandatory, so every .NET 10
MAUI iOS app built with Xcode 27 needs a UIApplicationSceneManifest.
Apps that still set Application.MainPage then crash with
"InvalidOperationException: Window was already destroyed" on every
force-close from the app switcher: SceneDidDisconnect destroys the
window, the destroyed MainPage window stays in Application.Windows, and
the WillTerminate handler destroys it again. Seen in production crash
reports of a shipping .NET 10 app (MAUI 10.0.110, iOS 27.2.1).

Changes (cherry-picked from #40452):
- WillTerminate only destroys a window whose handler is still connected
(Destroying() disconnects it), so a window the scene already destroyed
is skipped; a terminate without a prior scene disconnect still destroys
the window.
- WindowTests.WillTerminateDestroysMainPageWindowOnce (iOS / Mac
Catalyst device test), both with and without a prior scene disconnect.

The test file had a .NET 11 only test in the original PR; in
release/10.0.1xx-sr14 the iOS WindowTests partial was empty, so only the
new test and its stub were added.

---------

Co-authored-by: Mykhailo Davydenko <davudenko.mukhailo@gmail.com>
@kubaflo

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 — 1 finding

Reviewed commit a7e0612.

Previously reported findings were not duplicated.

…ermination (#40589)

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

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

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

Backports #40310 to .NET MAUI 10 SR14. When WebKit terminates a WebView
content process, the navigation delegate raises `ProcessTerminated` and
reloads the current page or HTML source. Automatic reloads are limited
to once every 30 seconds to prevent a reload loop.

**Validation:** On an iOS 18.5 simulator, the three new WebView
regression tests failed on the unfixed SR14 baseline and passed in two
runs with the combined Shell and WebView backports. The split WebView
branch built successfully for the iOS simulator; its separate test run
was stopped before completion.

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

Backports the fix for #39973.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
<!-- 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!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

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

Backports #40221 to .NET MAUI 10 SR14. On iOS and Mac Catalyst 18+, the
Shell renderer mirrors an opaque, solid page background onto the native
tab controller during tab switches and restores its previous background
when appropriate. The newer Shell handler is not present in .NET 10, so
this backport covers the renderer only.

**Validation:** On an iOS 18.5 simulator, the three new Shell regression
tests failed on the unfixed SR14 baseline and passed in two runs with
the combined Shell and WebView backports. An unrelated
`ShellTests.TitleViewConstraints` test failed on both the baseline and
fixed runs. The split Shell branch built successfully for the iOS
simulator; its separate test run was stopped before completion.

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

Backports the fix for #39800.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
@kubaflo

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 — 8 findings · ⚠️ 1 breaking change

Reviewed commit 25c4d78.

Warning

Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:

See inline comments for details.

state.Overridden = true;
}

view.BackgroundColor = color.ToPlatform();

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.

[major] Behavioral Change Disclosure - On iOS/Mac Catalyst 18+, a custom ShellRenderer can set its ShellItemRenderer.View.BackgroundColor to a deliberate transition backdrop. Previously that color survived tab switches; now switching between opaque solid-colored pages overwrites it with each page's color. Capturing the previous color only restores it when a page stops qualifying, so it does not preserve this working customization. Make background mirroring an explicit opt-in for this servicing target, keeping the previous backing-view behavior by default.

<!-- Used by Maui40045Tests to run the CA2252 analyzer over generated code -->
<Target Name="_AddNetAnalyzersPathMetadata" BeforeTargets="GetAssemblyAttributes" DependsOnTargets="ResolveLockFileAnalyzers">
<ItemGroup>
<AssemblyMetadata Include="NetAnalyzersPath" Value="%(Analyzer.FullPath)" Condition="'%(Analyzer.Filename)' == 'Microsoft.CodeAnalysis.NetAnalyzers'" />

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.

[moderate] Build & MSBuild - This embeds the build machine's absolute analyzer path into the test assembly. eng/helix.proj sends this project to Windows and macOS workers, but its correlation payloads do not recreate or remap that SDK/NuGet location. Maui40045Tests.GetPreviewFeaturesAnalyzers passes the embedded path directly to AnalyzerFileReference and throws on analyzer-load failure, so the relocated test fails before checking CA2252. Copy the required analyzer assemblies into the test payload and resolve them relative to the test assembly instead.

if (handler is null || !handler.IsConnected() || handler.VirtualView is not IWebView virtualView)
return;

virtualView.ProcessTerminated(new WebProcessTerminatedEventArgs(webView));

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.

[moderate] Handler Mapper and Property Patterns - Check handler.PlatformView == webView before raising ProcessTerminated. Disconnect leaves the old WKWebView's navigation delegate attached; reconnecting the same handler creates a new native view. If the retained old view then reports process termination, IsConnected succeeds and this line delivers the old view's event to the newly attached virtual view. The identity check afterward prevents a reload but cannot undo the incorrect application notification. Cover reconnecting a handler while its old native view remains alive.

virtualView.ProcessTerminated(new WebProcessTerminatedEventArgs(webView));

// The app's ProcessTerminated handler may have disconnected the handler or swapped its views.
if (!handler.IsConnected() || handler.VirtualView != virtualView || handler.PlatformView != webView)

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.

[moderate] iOS/macCatalyst Platform Specifics - A ProcessTerminated subscriber can set Source to fallback HTML with a different BaseUrl without replacing the handler or either view. LoadHtml updates HtmlUrl synchronously, but WKWebView.Url still represents the previously committed page until the replacement navigation commits. This guard allows recovery to continue, and the URL mismatch below calls Reload on the old page, superseding the subscriber's replacement load. Track source/navigation changes across the event and skip automatic recovery when the subscriber has already started a load; add that reentrant recovery case.

LastProcessTerminationReload = now;

// Restore an HTML source only while its document is shown; a page the user moved on to reloads itself.
if (webView is MauiWKWebView { HtmlUrl: { } htmlUrl } && webView.Url?.AbsoluteString?.Split('#')[0] is { } url && url != htmlUrl)

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.

[moderate] iOS/macCatalyst Platform Specifics - A different URL does not necessarily mean the injected HTML document was left. HTML using the default bundle base can call history.replaceState(null, '', '?route=details') without loading another document. Following process termination, the changed query makes this condition choose native Reload instead of supplying the in-memory HTML again, so recovery attempts a file URL rather than restoring the document. Track document-changing navigation separately from same-document URL changes and cover query-state changes on an HTML source; the current fragment test uses a URL source.

if (webView is MauiWKWebView { HtmlUrl: { } htmlUrl } && webView.Url?.AbsoluteString?.Split('#')[0] is { } url && url != htmlUrl)
webView.Reload();
else
webView.UpdateReload(virtualView);

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.

[moderate] Logic and Correctness Verification - HTML recovery misses subclasses such as CustomHtmlSource : HtmlWebViewSource. The inherited Load method supplies HTML and sets HtmlUrl normally, so termination on that document reaches UpdateReload here. However, that helper recognizes HTML only when Source.GetType().Name equals "HtmlWebViewSource"; a subclass takes native Reload instead of supplying its HTML, retaining the blank-content failure. Base recovery on the source's loading behavior rather than its exact type name, and add a derived-HTML-source case.

{
// A page with Opacity < 1 is meant to show what is behind it, so its
// background must not be mirrored onto the opaque backing view.
if (!OperatingSystem.IsIOSVersionAtLeast(18) && !OperatingSystem.IsMacCatalystVersionAtLeast(18))

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.

[moderate] Regression Prevention and Test Coverage - This transparency test changes Page.Opacity while its background stays fully opaque, so it never exercises the independent color.Alpha rejection in UpdateTabSwitchBackground. Removing that rejection leaves all three tests satisfied. Add a case with Page.Opacity = 1 that changes an opaque BackgroundColor to a partially transparent color and asserts restoration of the captured backing color. This distinguishes color alpha from page opacity and protects against compositing a translucent page over another copy of its background.

var terminated = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
webView.Navigated += (_, e) => navigated.TrySetResult(e.Result);
webView.ProcessTerminated += (_, _) => terminated.TrySetResult();

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.

[moderate] Regression Prevention and Test Coverage - The only ProcessTerminated subscriber merely signals completion, so none of these tests exercises the new post-event disconnect guard. Add a case whose subscriber disconnects the handler, asserting that notification occurs but recovery does not reload or access the disconnected view. All current recovery/cooldown tests keep the same handler connected and would accept removal of that guard, leaving this explicitly supported reentrant lifecycle case unprotected.

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — b474cdfe Deployed Nov 13, 2026 by kubaflo via conclusion #2944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants