Skip to content

[iOS/Mac Catalyst 26] Match the Shell overflow button tint to the other toolbar items - #40496

Open
edgiardina wants to merge 5 commits into
dotnet:net11from
edgiardina:fix/40495-overflow-tint
Open

edgiardina wants to merge 5 commits into
dotnet:net11from
edgiardina:fix/40495-overflow-tint

Conversation

@edgiardina

Copy link
Copy Markdown
Contributor

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

Description of Change

On iOS 26 and Mac Catalyst 26, the "..." overflow button for secondary toolbar items can have a different tint from the primary toolbar items next to it. This occurs when Shell.ForegroundColor is set on a TabBar or a ShellItem, not on the Shell or the page.

Cause:

  • Since [iOS/Mac Catalyst] Add native element registrations for DevFlow #36821, the overflow button is a UIButton in a UIBarButtonItem custom view.
  • UpdateRightBarButtonItemTintColors reads Shell.ForegroundColor only from Shell.CurrentPage and Shell. In this case the value is null, so it sets TintColor = null on each item and on each custom view.
  • A UIBarButtonItem with a null tint draws in the label color.
  • A UIView with a null tint uses the tint of its superview. ShellNavBarAppearanceTracker sets the navigation bar tint from ShellAppearance, which includes the TabBar foreground color. Thus the overflow button gets that color and the other items do not.

Fix: when the foreground color is null, set the custom view tint to UIColor.Label. This is the color that the plain bar button items use, and it is the overflow button color before #36821. When a foreground color is found, the behavior does not change.

Verification: the public repro (https://github.com/edgiardina/MauiOverflowTintRepro) applies the same tint to the same view in an app-side workaround. On an iPhone 17 simulator with iOS 27.2 in dark mode, the overflow button changes from blue (RGB 84, 141, 237) to white (RGB 250, 250, 250). The primary icon is white (RGB 252, 252, 252). In MAUI 10.0.110, before #36821, both are white.

Tests: Issue40495 adds a HostApp page and a screenshot test (iOS and Mac Catalyst). The test is based on Issue34083. This PR does not include the snapshot baselines. I can add the baselines from the CI run artifacts.

Issues Fixed

Fixes #40495

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

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

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

Or

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

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

Copy link
Copy Markdown
Contributor

Hey there @edgiardina! 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.

@kubaflo

kubaflo commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

/review expert-review-with-gate

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

Copy link
Copy Markdown
Contributor

Warning

Your /review gate couldn't start due to a transient error triggering the pipeline. The command was left unacknowledged so scheduled recovery can retry it automatically; you can also comment /review gate again in a minute.

@github-actions github-actions Bot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 22, 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 — 2 findings

Reviewed commit 011c618.

See inline comments for details.

public void OverflowButtonMatchesPrimaryToolbarItemTint()
{
App.WaitForElement("Issue40495_DescriptionLabel");
VerifyScreenshot();

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 - VerifyScreenshot defaults to this method's name, but no OverflowButtonMatchesPrimaryToolbarItemTint.png baseline is included for either Apple platform. VisualRegressionTester.VerifyMatchesSnapshot explicitly throws when the baseline is absent, even when the rendering is correct, so this test cannot yet compare the overflow tint against an approved image. Add the reviewed snapshots for the supported iOS environments and Mac Catalyst using the existing capture dimensions and cropping.

tabBar.Items.Add(new ShellContent { Title = "Other", Content = new ContentPage { Title = "Other" } });

// The foreground color is set on the TabBar, not on the Shell or the page.
Shell.SetForegroundColor(tabBar, Colors.Purple);

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 fixture covers only the null platformColor fallback: ForegroundColor is set on the TabBar, not on the page or Shell. An implementation that always assigns UIColor.Label to the overflow button would satisfy this case while breaking explicit page/Shell foreground colors. Issue34083 covers only a primary toolbar item, and Issue29499 is excluded on Apple platforms, so neither supplies the discriminating overflow-color assertion. Add a case with secondary items and an explicit page/Shell foreground, checking that the overflow uses that color and returns to the label color when it is cleared.

@kubaflo

kubaflo commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

/review run-tests

@github-actions

This comment has been minimized.

kubaflo and others added 4 commits November 22, 2026 19:06
…path (APT2260) (dotnet#40406)

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

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

### Description of Change

Build infrastructure only; no product or test code changes.

**Symptom.** Windows `Pack` (and occasionally `Build`) jobs fail
intermittently with `APT2260` in `Controls.Xaml` `net11.0-android37.0`
`Aapt2Link`: `style attribute 'attr/colorPrimary' not found` and other
Material attributes. Recent examples are net11 maui-pr
[1688582](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688582)
and candidate maui-pr
[1688577](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688577).
There have been 6 Pack and 2 Build Windows failures since 15 Nov, across
branches.

**Root cause.** `eng/Build.props` restores
`Microsoft.Maui.BuildTasks.slnf` with `BuildTaskOnlyBuild=true` first,
then the full solution filter, in the same MSBuild process:
1. Under CI, `BuildTaskOnlyBuild=true` disables the all-TFM group in
`Directory.Build.props`. The first restore therefore writes a reduced
`artifacts/obj/<project>/<project>.csproj.nuget.g.props/targets`, with
import groups only for `netstandard2.0`, `netstandard2.1` and `net11.0`.
2. The full restore's evaluations parse those same files into the
in-process `ProjectRootElementCache`, then rewrite them with all TFMs.
3. That cache does not revalidate timestamps: it is created with
`autoReloadFromDisk: false`, keeps 200 strong MRU entries and holds the
rest weakly. Later build evaluations can reuse the stale reduced XML, so
platform TFMs lose their `buildTransitive` package imports, including
the Material `AndroidAarLibrary` items. That produces `APT2260`. Whether
the stale entry survives depends on cache eviction and GC, which is why
the failure is intermittent.

CI binlogs show this directly. In failing build 1688582, the build-phase
evaluations of `Controls.Xaml` (ios/android/windows), `Controls.Core`
(ios/windows) and `Graphics` (android/windows) have zero package imports
from the `nuget.g.targets`. Passing net11 build
[1687936](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1687936)
has the normal import counts. dotnet#39779 serialized the two restores
(`RestoreInParallel=false`) but they still shared these generated files.
dotnet#40206 worked around the same mechanism for `Controls.Core` with
explicit package references.

**Fix.** For the build-task restore only, `Directory.Build.props` sets
`MSBuildProjectExtensionsPath` to
`$(BaseIntermediateOutputPath)buildtasks\`, so that restore writes
`nuget.g.*`, `project.assets.json` and dgspec files under
`artifacts/obj/<project>/buildtasks/`. The full restore and build keep
the default `artifacts/obj/<project>/` path, and the full restore's
evaluations never read the reduced files. Arcade's `ProjectLayout.props`
sets only `BaseIntermediateOutputPath`, and `Microsoft.Common.props`
defaults `MSBuildProjectExtensionsPath` after importing
`Directory.Build.props`, so this is the supported place to set it.
Nothing in the repo reads these paths directly. Other
`BuildTaskOnlyBuild` callers (`eng/cake/dotnet.cake`,
`eng/pipelines/arcade/setup-test-env.yml`) restore before every later
build, so they also stop overwriting the full assets. The comment in
`eng/Build.props` is updated to match.

Rejected alternatives:
- `MSBUILDNOINPROCNODE=1`: pipeline-wide behaviour change.
- More explicit package references, as in dotnet#40206: a per-project
workaround that doesn't remove the shared state.
- Disabling project-extension imports: unsafe.

### Validation

All runs used SDK 11.0.100 with `dotnet msbuild -m:1 -nodeReuse:false`.

**Minimal standalone repro.** A local package with `build/net10.0`
targets, consumed by a library whose TFMs shrink from `net11.0;net10.0`
to `net11.0` under `BuildTaskOnlyBuild=true`. The driver runs the
reduced restore, then the full restore, then reads the package marker
for `net10.0`:

| Run | Result |
| --- | --- |
| Baseline | marker missing (red) |
| Fix | marker present (green) |
| Fix reverted | marker missing (red) |
| Fix restored | marker present (green) |
| Control: baseline with `MSBUILDNOINPROCNODE=1` | marker present
(green): the in-proc XML cache is the mechanism |

**Repo-level repro, in Arcade's order.** The driver runs a
`BuildTasks.slnf` restore with `BuildTaskOnlyBuild=true`, then a full
`Controls.Xaml` restore, then an evaluation of `Controls.Xaml`
`net11.0-android37.0` that counts `AndroidAarLibrary` items. All runs
used `CI=true -p:IncludeMacOSTargetFrameworks=false`.
`MSBUILDPROJECTROOTELEMENTCACHESIZE=100000` stops strong-cache eviction,
which makes the CI intermittency deterministic:

| Run | AndroidAarLibrary (all / Material) | Package imports in the
build-phase android evaluation |
| --- | --- | --- |
| Baseline | 0 / 0 (red) | 31: the stale reduced `nuget.g.targets` |
| Fix | 69 / 1 (green) | 133 |
| Fix reverted | 0 / 0 (red) | — |
| Fix restored | 69 / 1 (green) | — |

With default cache settings the baseline was green locally (69/1), which
is consistent with the eviction-dependent intermittency seen in CI.

**Other checks.**
- Evaluation with `BuildTaskOnlyBuild=true`:
`MSBuildProjectExtensionsPath`, `RestoreOutputPath` and
`ProjectAssetsFile` point at `artifacts/obj/Controls.Xaml/buildtasks/`.
Without it they stay at `artifacts/obj/Controls.Xaml/`.
- `CI=true dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:BuildTaskOnlyBuild=true -p:IncludeMacOSTargetFrameworks=false`: build
succeeded, 0 warnings. All 12 restored projects wrote their assets under
`artifacts/obj/<project>/buildtasks/`.

The CI proof will be a Pack run's Windows binlog: the full restore's
evaluations should no longer import a normal-path `nuget.g.targets`
written by the build-task restore.

### Issues Fixed

Intermittent Windows Pack/Build `APT2260` failures in maui-pr. No issue
is filed; this was found while triaging dotnet#40116 CI.

Fixes #

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…net#40412)

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

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

### Description of Change

Test-only. On Android, `App.DismissKeyboard()` calls Appium's
`hideKeyboard`. That sends ESC, and if the IME is still reported as
shown about a second later, it also sends BACK. When the IME hide takes
longer than that, BACK closes the test page's `MainActivity` and the
launcher comes to the front. The next element lookup then throws a
`NullReferenceException` or times out.

This is the same mechanism as dotnet#40361 (Issue35119). There, BACK cancelled
a prompt.

The fix replaces the three Android `DismissKeyboard()` calls in
`Issue28986_ContentPage` (`SafeAreaPerEdgeValidation`,
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`) and
`Issue28986.SafeAreaPerEdgeValidation` with a helper:
- It waits for the keyboard to show.
- It sends only ESC, which the visible IME consumes.
- It asserts that the keyboard hides.

iOS still calls `DismissKeyboard()`. No assertions, tolerances or
baselines change. The keyboard tests in
`Issue28986_SafeAreaBorderOrientation` are excluded on Android
(`TEST_FAILS_ON_ANDROID`), so they are unchanged.

**CI evidence.** Candidate UI 1689104, SafeAreaEdges API36 (log 2836):
- The original attempt hit an NRE in `Tap("GridResetAllButton")` at line
156, right after `DismissKeyboard()` and a passing
`WaitForKeyboardToHide()`.
- Logcat shows ESC to Gboard, then the app's `onRequestHide`, then
`onHidden` after a stalled IME dump. Then a `Transition CLOSE` for the
app task brings the launcher to the front.
- The same NRE@156 signature appears in UI builds 1687709 and 1687330.

**Local causal validation.** Android 16 (API 36) emulator, `net11`
Material3 HostApp APK from UI build 1688901, filter
`Name=SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle|Name=SafeAreaPerEdgeValidation`
(3 tests per run):

| Phase | Runs | Failed tests |
| --- | --- | --- |
| Baseline (`net11`) | 3 | 9/9 |
| Fixed | 3 | 1/9 |
| Fix reverted | 3 | 6/9 |
| Fix restored | 3 | 1/9 |

- Baseline failures match CI: NRE at `Issue28986_ContentPage.cs:156`
(4), timeout at line 105 (4), a failure at line 126 (1), and timeout in
`Issue28986.cs` at line 193 (6). Each comes after ESC, then `onHidden`,
then a mid-test `Transition CLOSE` of the uitests task. The app
relaunches only after the timeout.
- Both fixed-run failures are in
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` at line 121. That is
the earlier "keyboard shown" assertion, before any hide. Logcat shows no
`onRequestShow` in those runs, so the keyboard was never requested. This
is a separate, pre-hide failure that this PR doesn't address.

### Issues Fixed

Fixes CI flakiness in
`Issue28986_ContentPage.SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`,
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` and
`Issue28986.SafeAreaPerEdgeValidation` on Android.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…t#40409)

This pull request updates the following dependencies

[marker]: <> (Begin:fc4a0e63-cc9b-414d-9375-11dd045dcfa9)
## From https://github.com/dotnet/android
- **Subscription**:
[fc4a0e63-cc9b-414d-9375-11dd045dcfa9](https://maestro.dot.net/subscriptions?search=fc4a0e63-cc9b-414d-9375-11dd045dcfa9)
- **Build**:
[11.0.1xx-d644ae60c9c7cff27a9813663298c3aa642534a3-1](https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=16070009)
([342149](https://maestro.dot.net/channel/8298/github:dotnet:android/build/342149))
- **Date Produced**: November 18, 2026 9:02:56 PM UTC
- **Commit**:
[d644ae60c9c7cff27a9813663298c3aa642534a3](dotnet/android@d644ae6)
- **Branch**:
[release/11.0.1xx](https://github.com/dotnet/android/tree/release/11.0.1xx)

[DependencyUpdate]: <> (Begin)

- **Dependency Updates**:
  - From [37.2.40 to 37.2.43][1]
     - Microsoft.Android.Sdk.Windows

[1]: dotnet/android@37b3691...d644ae6

[DependencyUpdate]: <> (End)


[marker]: <> (End:fc4a0e63-cc9b-414d-9375-11dd045dcfa9)



[marker]: <> (Begin:0340b3ac-0154-4d65-98b8-f534ebc24108)
## From https://github.com/dotnet/dotnet
- **Subscription**:
[0340b3ac-0154-4d65-98b8-f534ebc24108](https://maestro.dot.net/subscriptions?search=0340b3ac-0154-4d65-98b8-f534ebc24108)
- **Build**:
[20261117.5](https://dev.azure.com/dnceng/internal/_build/results?buildId=3138553)
([342028](https://maestro.dot.net/channel/8298/github:dotnet:dotnet/build/342028))
- **Date Produced**: November 18, 2026 7:22:18 AM UTC
- **Commit**:
[81e781b0429cbad5d1984bce95e451bba6aeab0e](dotnet/dotnet@81e781b)
- **Branch**:
[release/11.0.1xx](https://github.com/dotnet/dotnet/tree/release/11.0.1xx)

[DependencyUpdate]: <> (Begin)

- **Dependency Updates**:
  - From [11.0.1 to 11.0.1][2]
     - Microsoft.AspNetCore.Authentication.Facebook
     - Microsoft.AspNetCore.Authentication.Google
     - Microsoft.AspNetCore.Authentication.MicrosoftAccount
     - Microsoft.AspNetCore.Authorization
     - Microsoft.AspNetCore.Components
     - Microsoft.AspNetCore.Components.Analyzers
     - Microsoft.AspNetCore.Components.Forms
     - Microsoft.AspNetCore.Components.Web
     - Microsoft.AspNetCore.Components.WebAssembly
     - Microsoft.AspNetCore.Components.WebAssembly.Server
     - Microsoft.AspNetCore.Components.WebView
     - Microsoft.AspNetCore.Metadata
     - Microsoft.Extensions.Configuration
     - Microsoft.Extensions.Configuration.Abstractions
     - Microsoft.Extensions.Configuration.Json
     - Microsoft.Extensions.DependencyInjection
     - Microsoft.Extensions.DependencyInjection.Abstractions
     - Microsoft.Extensions.FileProviders.Abstractions
     - Microsoft.Extensions.Hosting.Abstractions
     - Microsoft.Extensions.Logging
     - Microsoft.Extensions.Logging.Abstractions
     - Microsoft.Extensions.Logging.Console
     - Microsoft.Extensions.Logging.Debug
     - Microsoft.Extensions.Primitives
     - Microsoft.JSInterop
     - Microsoft.NETCore.App.Ref
  - From [11.0.0-beta.26566.116 to 11.0.0-beta.26567.105][2]
     - Microsoft.DotNet.Arcade.Sdk
     - Microsoft.DotNet.Build.Tasks.Feed
     - Microsoft.DotNet.Build.Tasks.Installers
     - Microsoft.DotNet.Build.Tasks.Workloads
     - Microsoft.DotNet.Helix.JobMonitor
     - Microsoft.DotNet.Helix.Sdk
     - Microsoft.DotNet.RemoteExecutor
     - Microsoft.DotNet.SharedFramework.Sdk
     - Microsoft.DotNet.XUnitExtensions
- From [11.0.101-servicing.26566.116 to 11.0.101-servicing.26567.105][2]
     - Microsoft.NET.Sdk

[2]: dotnet/dotnet@f41eb11...81e781b

[DependencyUpdate]: <> (End)


[marker]: <> (End:0340b3ac-0154-4d65-98b8-f534ebc24108)

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…r/DragLeave (dotnet#40441)

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

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

### Description of Change

On iOS, `DragEventArgs.GetPosition()` can throw a
`NullReferenceException` inside a `DragOver` or `DragLeave` handler. The
exception crashes the app.

**CI evidence.** The `DropEventCoordinates` UI test crashed the HostApp
on both attempts on the iOS CoreCLR lane of SR2 candidate dotnet#40116
(maui-pr-uitests
[1690394](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1690394),
iOS latest Editor..Fr job). The job's `.ips` reports show SIGABRT from
`xamarin_process_managed_exception` under `-[UIDropInteraction
_dragDestinationGestureStateChanged:]`. The logarchive shows the managed
exception:

```
System.NullReferenceException
  at DragAndDropDelegate.CalculatePosition(IElement, WeakReference, WeakReference)
  at DragAndDropBetweenLayouts.OnDragOver(...)        // HostApp calls e.GetPosition(...)
  at DragAndDropDelegate.<HandleDragOver>...
  at DragAndDropDelegate.SendEventArgs(...)
  at DragAndDropDelegate.HandleDragOver(...)
  at DragAndDropDelegate.SessionDidUpdate(...)
```

**Root cause.**
- `SessionDidUpdate` and `SessionDidExit` pass
`session.LocalDragSession`, a transient managed wrapper of the native
local drag session, into `HandleDragOver` and `HandleDragLeave`.
- Those methods put only a `WeakReference` to it in the `GetPosition`
callback, and nothing else on the path keeps it alive:
`PlatformDragEventArgs` holds the outer `IUIDropSession`, not the local
drag session.
- A GC while the user's handler is running can therefore collect the
wrapper. `CalculatePosition` then calls `LocationInView` on a null
session.
- Separately, `HandleDragOver` built a weak reference even when
`LocalDragSession` is null (a drag from another app), so `GetPosition`
always threw in that case. `HandleDragLeave` and `HandleDrop` already
return null there.

The weak references date from 2023, and the code is identical on
`net11`, the candidate and `main`. This is a latent bug that the CoreCLR
lane's GC timing exposed, not a candidate regression.

**Fix** (`DragAndDropDelegate.cs`, iOS/Mac Catalyst):
- `HandleDragOver` and `HandleDragLeave` call `GC.KeepAlive(session)`
after dispatching to the recognizers. The session stays alive while
handlers can synchronously call `GetPosition`, and the event args still
don't hold it strongly.
- `HandleDragOver` uses a null `sessionRef` when there is no local drag
session, matching `HandleDragLeave` and `HandleDrop`.
- `CalculatePosition` returns `null` when the session reference is
missing or its target has already been collected, instead of
dereferencing null. This covers a `GetPosition` call made after the
handler returns.

**Tests** (`DragAndDropTests.iOS.cs`, `Gesture` category):
- `DragPositionIsAvailableAfterGarbageCollectionDuringHandler(dragLeave:
false/true)`: a fake drop session returns a fresh local drag session
wrapper each time, the handler forces a full GC and then calls
`GetPosition`, and the test asserts the fake session's location.
- `DragOverPositionIsNullWithoutLocalDragSession`: with no local drag
session, `GetPosition` in `DragOver` returns `null`.

**Validation** (iOS 18.5 simulator, Release, CoreCLR, the same runtime
as the failing CI lane):

| Command | Result |
| --- | --- |
| `pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1
-Project Controls -Platform ios -TestFilter "Category=Gesture"
-DeviceUdid <iOS 18.5 sim> -SkipXcodeVersionCheck` with only the new
tests (no fix) | **Failed**: 45 passed, 3 failed. All three new cases
throw `NullReferenceException` at
`DragAndDropDelegate.CalculatePosition`, the same frame as the CI crash.
|
| Same command with the fix | **Passed**: 48 passed, 0 failed |
| `dotnet format whitespace --folder --include <changed files>
--verify-no-changes` | Passed |

The UI test itself was not rerun locally, because its crash depends on
when a GC happens.

### Issues Fixed

No existing issue; found while investigating SR2 candidate dotnet#40116 CI.
Searched for related issues and PRs and found no duplicate.
dotnet#28416/dotnet#28417 is an unrelated Mac Catalyst `DragAndDropDelegate` NRE.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
### Description of Change

`/review run-tests` refused every PR targeting `net11` (e.g. #40496:
"that branch's maui-pr-uitests pipeline does not build run-tests/*
dispatches"). `net11` and the `inflight/*` branches were cut before
run-tests support, and backporting the selection pipeline (~700 lines
across 7 pipeline files) to every servicing branch isn't practical.

Now, when the target branch's `eng/pipelines/ci-uitests.yml` can't build
`run-tests/*` dispatches, the dispatch commit takes `eng/pipelines` and
`.github` from the default branch instead. The PR's code still comes
from its test-merge commit (PR head merged into its real target), so the
tests run against `net11` code.

- `Invoke-RunTests.ps1`: try the target branch, then the default branch;
error only if neither supports dispatch.
- `Get-RunTestsContext.ps1`: the early "unsupported" gate applies only
if neither branch supports it.

`main` and `net11` differ in `eng/pipelines` only by the run-tests
selection pieces, and in `eng/` only by dependency versions, so `main`'s
pipeline builds `net11` code.

### Verification

Trial on #40496 (targets `net11`) with the patched script: it logged
"`net11` cannot build run-tests/* dispatches; trying the default
branch's pipeline", pushed `run-tests/pr40496-1795400001`, and
maui-pr-uitests build 1694022 started with only iOS/MacCatalyst `Shell1`
+ `ToolbarItem` (no comment was posted for the trial).

`RunTests.Tests.ps1` + `CopilotPipeline.Tests.ps1`: 69 passed.

### Issues Fixed

N/A

Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
@kubaflo

kubaflo commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

/review run-tests

@github-actions

This comment has been minimized.

…er toolbar items

Since dotnet#36821 the overflow button for secondary toolbar items is a UIButton
custom view. When no Shell.ForegroundColor is found on the page or the
Shell, UpdateRightBarButtonItemTintColors sets its tint to null. A UIView
with a null tint inherits the navigation bar's tint, which ShellAppearance
sets from a TabBar or ShellItem foreground color, so the overflow button
turns that color while the plain bar button items next to it draw in the
label color. Use the label color for custom views in that case.

Fixes dotnet#40495

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R5ENwYPkVTpXYPhHXyymHo
@kubaflo
kubaflo force-pushed the fix/40495-overflow-tint branch from 011c618 to 3d8ae5d Compare November 23, 2026 11:15
@kubaflo

kubaflo commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

/review expert-review-with-gate

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

Copy link
Copy Markdown
Contributor

Warning

Your /review gate couldn't start due to a transient error triggering the pipeline. The command was left unacknowledged so scheduled recovery can retry it automatically; you can also comment /review gate again in a minute.

@github-actions github-actions Bot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 23, 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 — 2 findings

Reviewed commit 3d8ae5d.

See inline comments for details.

public void OverflowButtonMatchesPrimaryToolbarItemTint()
{
App.WaitForElement("Issue40495_DescriptionLabel");
VerifyScreenshot();

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 - VerifyScreenshot defaults to OverflowButtonMatchesPrimaryToolbarItemTint, but the frozen source contains no corresponding PNG baseline for either Apple platform. VisualRegressionTester.VerifyMatchesSnapshot throws when the baseline is absent, even with correct rendering, so this test cannot compare the overflow tint against an approved image. Add reviewed baselines for the applicable iOS snapshot environments and Mac Catalyst using the existing screenshot capture and cropping.

tabBar.Items.Add(new ShellContent { Title = "Other", Content = new ContentPage { Title = "Other" } });

// The foreground color is set on the TabBar, not on the Shell or the page.
Shell.SetForegroundColor(tabBar, Colors.Purple);

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 fixture exercises only the null platformColor fallback: ForegroundColor is set on the TabBar, never on the page or Shell. An implementation that unconditionally assigns UIColor.Label to the overflow would produce the same screenshot here while breaking explicit page/Shell foreground tint on iOS/Mac Catalyst 26+, the behavior preserved from #34085. Issue34083 has only a primary item; the existing secondary-toolbar device test checks menu metadata, not tint. Add a discriminating case with secondary items and a distinct explicit page/Shell foreground, then clear it and verify the overflow returns to label color.

// button) the label color in that case so they match the items next to them.
if (item.CustomView is UIView customView)
customView.TintColor = platformColor;
customView.TintColor = platformColor ?? UIColor.Label;

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.

Could we avoid hard-coding UIColor.Label as the fallback? This overrides the custom view’s normal inherited tint, which can suppress an explicitly configured navigation-bar tint. Please derive the effective toolbar tint from Shell appearance and apply it consistently to the overflow and primary items, while retaining the native default when no foreground color is configured.

@kubaflo

kubaflo commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

/review run-tests

@github-actions

Copy link
Copy Markdown
Contributor

Selected UI Tests

@kubaflo — AI-selected UI tests (GPT-6.2 Sol + Claude Opus 5.5) for commit 3d8ae5d8.

Result NOT QUEUED Platforms iOS, MacCatalyst Categories 3 of 77 Commit 3d8ae5d8


🧪 Test selection — click to expand

❌ Could not queue maui-pr-uitests: GitHub has no test-merge commit for this PR head (it may have merge conflicts, or GitHub is still computing it). Resolve conflicts or retry /review run-tests.

GPT-6.2 Sol: Run Shell UI tests on iOS and Mac Catalyst for the toolbar overflow tint fix.
Claude Opus 5.5: iOS/MacCatalyst Shell toolbar overflow button tint fix; runs Shell and ToolbarItem UI tests on iOS and MacCatalyst.

🧪 Running — 3 categories on iOS, MacCatalyst

Platform Categories
iOS Shell1, Shell2, ToolbarItem
MacCatalyst Shell1, Shell2, ToolbarItem
⏭️ Skipped — 74 categories, 2 platforms

Platforms not run: Android, Windows

Categories not run: Accessibility, ActionSheet, ActivityIndicator, Animation, AppLinks, Border, BoxView, Brush, Button, CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DisplayPrompt, DragAndDrop, Entry, Editor, Effects, Essentials, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, Lifecycle, ManualReview, Maps, Navigation, Page, Performance, Picker, ProgressBar, RadioButton, RefreshView, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, TabbedPage, TableView, TimePicker, TitleView, Triggers, ViewBaseTests, VisualStateManager, Window, WebView, Material3

Each skipped platform and category is listed as a Skipped maui-pr-uitests (skipped) … check on this commit. Use /azp run maui-pr-uitests for the full suite.

🤖 Why these tests — AI rationale (GPT-6.2 Sol + Claude Opus 5.5)

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol Claude Opus 5.5
Android — —
iOS Shell1, Shell2 Shell1, Shell2, ToolbarItem
MacCatalyst Shell1, Shell2 Shell1, Shell2, ToolbarItem
Windows — —

GPT-6.2 Sol — Run Shell UI tests on iOS and Mac Catalyst for the toolbar overflow tint fix.

  • ShellPageRendererTracker changes custom toolbar item tint only on iOS and Mac Catalyst.
  • The Issue40495 page and Shell2 screenshot test cover the overflow tint on both.
  • Skip Android, Windows, and non-Shell suites: no shared toolbar or navigation code changed.

Claude Opus 5.5 — iOS/MacCatalyst Shell toolbar overflow button tint fix; runs Shell and ToolbarItem UI tests on iOS and MacCatalyst.

  • Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs is iOS code (also compiled for MacCatalyst) → ios, maccatalyst.
  • New test Issue40495 is #if IOS || MACCATALYST, category Shell (shard 2) → Shell umbrella.
  • Change affects toolbar item tint colors (UpdateRightBarButtonItemTintColors) → ToolbarItem.
  • Android/Windows untouched; no other controls affected.

Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.

devanathan-vaithiyanathan pushed a commit to devanathan-vaithiyanathan/maui that referenced this pull request Nov 24, 2026
### Description of Change

`/review run-tests` refused every PR targeting `net11` (e.g. dotnet#40496:
"that branch's maui-pr-uitests pipeline does not build run-tests/*
dispatches"). `net11` and the `inflight/*` branches were cut before
run-tests support, and backporting the selection pipeline (~700 lines
across 7 pipeline files) to every servicing branch isn't practical.

Now, when the target branch's `eng/pipelines/ci-uitests.yml` can't build
`run-tests/*` dispatches, the dispatch commit takes `eng/pipelines` and
`.github` from the default branch instead. The PR's code still comes
from its test-merge commit (PR head merged into its real target), so the
tests run against `net11` code.

- `Invoke-RunTests.ps1`: try the target branch, then the default branch;
error only if neither supports dispatch.
- `Get-RunTestsContext.ps1`: the early "unsupported" gate applies only
if neither branch supports it.

`main` and `net11` differ in `eng/pipelines` only by the run-tests
selection pieces, and in `eng/` only by dependency versions, so `main`'s
pipeline builds `net11` code.

### Verification

Trial on dotnet#40496 (targets `net11`) with the patched script: it logged
"`net11` cannot build run-tests/* dispatches; trying the default
branch's pipeline", pushed `run-tests/pr40496-1795400001`, and
maui-pr-uitests build 1694022 started with only iOS/MacCatalyst `Shell1`
+ `ToolbarItem` (no comment was posted for the trial).

`RunTests.Tests.ps1` + `CopilotPipeline.Tests.ps1`: 69 passed.

### Issues Fixed

N/A

Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
HarishwaranVijayakumar pushed a commit to HarishwaranVijayakumar/maui that referenced this pull request Nov 24, 2026
### Description of Change

`/review run-tests` refused every PR targeting `net11` (e.g. dotnet#40496:
"that branch's maui-pr-uitests pipeline does not build run-tests/*
dispatches"). `net11` and the `inflight/*` branches were cut before
run-tests support, and backporting the selection pipeline (~700 lines
across 7 pipeline files) to every servicing branch isn't practical.

Now, when the target branch's `eng/pipelines/ci-uitests.yml` can't build
`run-tests/*` dispatches, the dispatch commit takes `eng/pipelines` and
`.github` from the default branch instead. The PR's code still comes
from its test-merge commit (PR head merged into its real target), so the
tests run against `net11` code.

- `Invoke-RunTests.ps1`: try the target branch, then the default branch;
error only if neither supports dispatch.
- `Get-RunTestsContext.ps1`: the early "unsupported" gate applies only
if neither branch supports it.

`main` and `net11` differ in `eng/pipelines` only by the run-tests
selection pieces, and in `eng/` only by dependency versions, so `main`'s
pipeline builds `net11` code.

### Verification

Trial on dotnet#40496 (targets `net11`) with the patched script: it logged
"`net11` cannot build run-tests/* dispatches; trying the default
branch's pipeline", pushed `run-tests/pr40496-1795400001`, and
maui-pr-uitests build 1694022 started with only iOS/MacCatalyst `Shell1`
+ `ToolbarItem` (no comment was posted for the trial).

`RunTests.Tests.ps1` + `CopilotPipeline.Tests.ps1`: 69 passed.

### Issues Fixed

N/A

Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
@kubaflo
kubaflo deleted the branch dotnet:net11 November 24, 2026 14:43
@kubaflo kubaflo closed this Nov 24, 2026
@kubaflo kubaflo reopened this Nov 24, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:48 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:49 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:50 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:52 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:53 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 14:54 — with GitHub Actions Inactive

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

Could you please fix this PR and check the ai' suggestions?

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 3d8ae5d8 Deployed Nov 24, 2026 by kubaflo via conclusion #3280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS 26+] Secondary toolbar overflow ("...") button gets Shell.ForegroundColor while the primary items do not, since 10.0.120 (regression from #36821)

2 participants