Skip to content

[iOS] Keep Shell tab switches from flashing the default white canvas - #40221

Merged
kubaflo merged 3 commits into
dotnet:candidate/11.0.1xx-sr2from
MykhailoDav:fix-39800-tab-grey-flash
Nov 14, 2026
Merged

kubaflo merged 3 commits into
dotnet:candidate/11.0.1xx-sr2from
MykhailoDav:fix-39800-tab-grey-flash

Conversation

@MykhailoDav

@MykhailoDav MykhailoDav commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even when every page and Shell color is black.

ShellItemRenderer never sets its UITabBarController view's background, so that view keeps UIKit's default, white in light mode. On iOS 18 the tab controller cross-fades tab switches, and a probe built into a two-tab black app caught UIKit fading a full-screen white backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over 4–5 frames). Black pages composited over white read as grey. Recoloring that one view red turned the flash red; coloring it black made the flash vanish while the native cross-fade kept running (401 animations over 10 switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the tab controller's view (and onto PlatformView in the handler path) on iOS and Mac Catalyst 18+. It captures the previous color the first time it overrides and restores it when the page background goes away. Translucent colors, gradients and pages with Opacity < 1 are left alone.

The earlier WIP attempt (#39893) was flagged for capturing state at ViewDidLoad before custom renderers run and for routing through UpdateBackground, which can delete externally applied gradient layers. This change avoids both by design: the capture is lazy, and only BackgroundColor is ever touched.

Tests / evidence

ShellTabSwitchBackgroundTests (iOS device test, Shell category, gated to iOS/Catalyst 18+): builds a two-tab Shell, locates the UITabBarController backing view, and asserts it adopts the displayed page's opaque black background, then restores the captured default when the background is cleared. No pixel sampling or display links involved. Review follow-up (3fcfbae) extends this with preconfigured backgrounds asserted across a real tab switch (no post-attach mutation), the Opacity < 1 exclusion sequence, and a second theory row that registers the handler-based Shell so the ShellItemHandler path runs too.

Without fix With fix
iOS Shell category (iOS 26.5 simulator) 508 of 510 passed; the only 2 failures are the new test under both Shell variants 518 passed, 0 failed (with the extended coverage)
Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11 switches a grey event (3–4 mid-grey frames) at every switch zero grey frames; the cross-fade still runs

Before / after (two-tab black sandbox app, iOS 18.5 simulator; both stills are mid-cross-fade frames, the tab labels blended):

Before: the page area washes grey during the switch After: it stays black, only the label fades
before after

Full clips: before.mp4 · after.mp4

Issues Fixed

Fixes #39800

On iOS/Mac Catalyst 18+ the tab-switch cross-fade composites the pages
over the tab controller's own view, so a backing color that does not
match the displayed page flashes during every switch (dotnet#39800). Assert
that the backing view adopts the displayed page's opaque background and
restores the captured default when the page background is cleared.
On iOS 18+ UITabBarController cross-fades tab switches over its own
view, which keeps UIKit's default background (white in light mode).
Pages with dark backgrounds composited over it flash grey during every
switch. Mirror the displayed page's solid background onto the backing
view, restore the captured default when the page background goes away,
and track page background and opacity changes while displayed.

Fixes dotnet#39800
@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 -- 40221

Or

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

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/ios platform/macos macOS / Mac Catalyst labels Nov 13, 2026
@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
@kubaflo

kubaflo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@MykhailoDav — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform iOS


🧪 Gate analysis — click to expand

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

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

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed 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 — 2 findings

Reviewed commit 7f8181c.

See inline comments for details.


var defaultBackground = backingView.BackgroundColor;

page.BackgroundColor = Colors.Black;

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 test sets black only after navigation and never selects Tab 2, so it still passes if the initial/displayed-page background updates are removed while the PropertyChanged update remains. That leaves #39800's preconfigured-black-page tab-switch scenario unprotected. Initialize backgrounds before attachment, switch tabs, and assert the backing color without further background mutations. Also exercise the opt-in Shell handler hierarchy: SetupBuilder registers ShellRenderer, and ShellNavigationHandlerTests changes only the NavigationPage registration, so neither variant exercises the changed ShellItemHandler callbacks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in 3fcfbae. The new theory sets black on Tab 1 and blue on Tab 2 before the shell attaches, switches to Tab 2, and asserts the backing color without touching any background after attach, so dropping the ViewDidLoad or OnDisplayedPageChanged call sites now fails it (the two tabs get different colors for exactly that reason). Each theory also has a second row that registers the four Shell handlers, the same way ShellHandlerBackNavigationRespectsChildBackButtonPressed does, so the ShellItemHandler.iOS.cs callbacks run end to end instead of only the compat renderer. Shell category on an iOS 26.5 simulator: 518 passed, 0 failed.

Assert.True(ColorComparison.ARGBEquivalent(Colors.Black.ToPlatform(), backingView.BackgroundColor),
"The backing view should adopt the displayed page's opaque black background.");

page.BackgroundColor = null;

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 - Clearing BackgroundColor does not exercise the new opacity exclusion or its property-change callback. Removing the page.Opacity guard would leave all assertions satisfied while an opaque black backing view remains beneath a partially transparent page. Keep BackgroundColor black, set Opacity below 1 and assert the captured default is restored, then restore Opacity to 1 and assert black is reapplied.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in 3fcfbae: the opacity test keeps BackgroundColor black, drops Opacity to 0.5 and asserts the captured default is restored, then sets Opacity back to 1 and asserts black is reapplied. Removing the opacity guard or the OpacityProperty filter entry now fails it. It runs under both the compat renderer and the handler-based Shell.

@azure-pipelines

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The background handling ignores image precedence and image-source changes, causing incorrect or stale tab-controller canvas colors for image-backed pages.

1 open issue
What changed in this PR

Addresses #39800’s grey flash during Shell tab switches by matching the tab-controller background to the displayed page’s opaque solid color on iOS and Mac Catalyst 18+, while preserving native transitions.

Changes:

  • Adds shared background capture, synchronization, and restoration logic that changes only BackgroundColor.
  • Updates both Shell implementations when the displayed page, background, or opacity changes.
  • Adds device tests for background restoration, preconfigured colors across tab switches, and reduced page opacity.
File Description
src/​Controls/​tests/​DeviceTests/​Elements/​Shell/​ShellTabSwitchBackgroundTests.iOS.cs Adds background synchronization and opacity tests, including both Shell implementations.
src/​Controls/​src/​Core/​Handlers/​Shell/​ShellItemHandler.iOS.cs Connects the handler path to background updates and resets saved state on disconnect.
src/​Controls/​src/​Core/​Compatibility/​Handlers/​Shell/​iOS/​ShellItemRenderer.cs Implements shared background tracking and integrates it with the compatibility renderer.

Review effort: Balanced

Comment on lines +107 to +109
var brush = page.Background;
if (Brush.IsNullOrEmpty(brush))
color = page.BackgroundColor;
@MauiBot

MauiBot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@MykhailoDav — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform iOS


🧪 Gate analysis — click to expand

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

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

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed 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 — 2 findings

Reviewed commit 3fcfbae.

See inline comments for details.

e.PropertyName == VisualElement.BackgroundProperty.PropertyName ||
e.PropertyName == VisualElement.OpacityProperty.PropertyName)
{
ShellItemRenderer.UpdateTabSwitchBackground(PlatformView, _displayedPage, _tabSwitchBackground);

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] Null Safety and Defensive Coding - With the opt-in Shell handlers, an earlier-registered page PropertyChanged subscriber can synchronously call shell.DisconnectHandlers() when BackgroundColor, Background or Opacity changes. This callback still runs from the event's captured invocation list despite being unsubscribed during teardown. ElementHandler.DisconnectHandler has already cleared PlatformView, so the typed PlatformView getter here throws InvalidOperationException before the helper's null guard executes. Guard the nullable IElementHandler.PlatformView before accessing the native view.

Assert.True(ColorComparison.ARGBEquivalent(Colors.Black.ToPlatform(), backingView.BackgroundColor),
"The backing view should adopt the displayed page's opaque black background.");

page.Opacity = 0.5;

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 opacity theory exercises page opacity, but every non-null background color in these tests has Alpha = 1. Removing the helper's color.Alpha < 1 exclusion therefore leaves all assertions satisfied while translucent page backgrounds are mirrored onto the backing view, changing their compositing. Add a discriminating sequence under both hierarchies that keeps page.Opacity = 1, changes an opaque background to a half-alpha color, and asserts the captured native default is restored, then changes back to an opaque color and asserts it is reapplied.

@kubaflo kubaflo mentioned this pull request Nov 14, 2026
1 task done
@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@MykhailoDav — test-failure analysis for commit 3fcfbae.

Scope CI failures Commit 3fcfbae


🧪 CI Analysis — click to expand
📊 maui-pr
  • 🟡 Needs human investigation: RunOniOS_BlazorDebug_CoreCLR, iOS ARM64: XHarness 83/missing completion marker after successful build. Inspect XHarness diagnostics; five target timelines are truncated.

🧪 maui-pr-devicetests

No failures found.


🧪 maui-pr-uitests

Target matches fail without this PR; the Shell-only diff leaves their assertions/setup unchanged.

**Insufficient (redacted) remaining setup diagnostics, target-history coverage, and VSM visual comparisons are unverified.


🧭 Follow-up — actions and refresh

Next action: inspect XHarness logs; compare five VSM screenshots with the base under identical MacCatalyst settings.

Maintainers: comment /review tests to refresh this report.

@kubaflo
kubaflo changed the base branch from main to candidate/11.0.1xx-sr2 November 14, 2026 12:16
@kubaflo
kubaflo merged commit dfcef20 into dotnet:candidate/11.0.1xx-sr2 Nov 14, 2026
139 of 184 checks passed
@kubaflo kubaflo mentioned this pull request Nov 14, 2026
1 task
kubaflo added a commit that referenced this pull request Nov 16, 2026
…40221)

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

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

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

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

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

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

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

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

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

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

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

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

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

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

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

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

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes #39800

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
kubaflo added a commit that referenced this pull request Nov 24, 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!

<!--
!!!!!!! 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.
-->
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…otnet#40221)

### Description of Change

On iOS 18.x, switching Shell tabs flashes grey for a few frames even
when every page and Shell color is black.

`ShellItemRenderer` never sets its `UITabBarController` view's
background, so that view keeps UIKit's default, white in light mode. On
iOS 18 the tab controller cross-fades tab switches, and a probe built
into a two-tab black app caught UIKit fading a full-screen white
backdrop between the outgoing and incoming pages (opacity 0 → 0.89 over
4–5 frames). Black pages composited over white read as grey. Recoloring
that one view red turned the flash red; coloring it black made the flash
vanish while the native cross-fade kept running (401 animations over 10
switches, zero grey frames). iOS 26 doesn't cross-fade at all, which is
why the report is 18.x-specific.

The fix mirrors the displayed page's solid opaque background onto the
tab controller's view (and onto `PlatformView` in the handler path) on
iOS and Mac Catalyst 18+. It captures the previous color the first time
it overrides and restores it when the page background goes away.
Translucent colors, gradients and pages with `Opacity < 1` are left
alone.

The earlier WIP attempt (dotnet#39893) was flagged for capturing state at
`ViewDidLoad` before custom renderers run and for routing through
`UpdateBackground`, which can delete externally applied gradient layers.
This change avoids both by design: the capture is lazy, and only
`BackgroundColor` is ever touched.

**Tests / evidence**

`ShellTabSwitchBackgroundTests` (iOS device test, Shell category, gated
to iOS/Catalyst 18+): builds a two-tab Shell, locates the
`UITabBarController` backing view, and asserts it adopts the displayed
page's opaque black background, then restores the captured default when
the background is cleared. No pixel sampling or display links involved.
Review follow-up (3fcfbae) extends this with preconfigured
backgrounds asserted across a real tab switch (no post-attach mutation),
the `Opacity < 1` exclusion sequence, and a second theory row that
registers the handler-based Shell so the `ShellItemHandler` path runs
too.

| | Without fix | With fix |
|---|---|---|
| iOS Shell category (iOS 26.5 simulator) | 508 of 510 passed; the only
2 failures are the new test under both Shell variants | 518 passed, 0
failed (with the extended coverage) |
| Frame scan of a two-tab black app on an iOS 18.5 simulator, ~11
switches | a grey event (3–4 mid-grey frames) at every switch | zero
grey frames; the cross-fade still runs |

**Before / after** (two-tab black sandbox app, iOS 18.5 simulator; both
stills are mid-cross-fade frames, the tab labels blended):

| Before: the page area washes grey during the switch | After: it stays
black, only the label fades |
|---|---|
|
![before](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.png)
|
![after](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.png)
|

Full clips:
[before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-before.mp4)
·
[after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/39800-after.mp4)

### Issues Fixed

Fixes dotnet#39800

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution platform/ios platform/macos macOS / Mac Catalyst

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Shell tab switching briefly flashes grey despite black page backgrounds

4 participants