Repository navigation
[iOS] Keep Shell tab switches from flashing the default white canvas - #40221
Conversation
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
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40221Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40221" |
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
/rebase |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 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. |
|
|
||
| var defaultBackground = backingView.BackgroundColor; | ||
|
|
||
| page.BackgroundColor = Colors.Black; |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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.
…acking-view tests
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 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
| var brush = page.Background; | ||
| if (Brush.IsNullOrEmpty(brush)) | ||
| color = page.BackgroundColor; |
PR Test Gate
🧪 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. |
| e.PropertyName == VisualElement.BackgroundProperty.PropertyName || | ||
| e.PropertyName == VisualElement.OpacityProperty.PropertyName) | ||
| { | ||
| ShellItemRenderer.UpdateTabSwitchBackground(PlatformView, _displayedPage, _tabSwitchBackground); |
There was a problem hiding this comment.
[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; |
There was a problem hiding this comment.
[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.
This comment has been minimized.
This comment has been minimized.
Tests Failure Analysis
🧪 CI Analysis — click to expand📊 maui-pr
🧪 maui-pr-devicetestsNo failures found. 🧪 maui-pr-uitestsTarget 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 refreshNext action: inspect XHarness logs; compare five VSM screenshots with the base under identical MacCatalyst settings.
|
dfcef20
into
dotnet:candidate/11.0.1xx-sr2
…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 | |---|---| |  |  | 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>
…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 | |---|---| |  |  | 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>
…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 | |---|---| |  |  | 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>
…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 | |---|---| |  |  | 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>
…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 | |---|---| |  |  | 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>
…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 | |---|---| |  |  | 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>
…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 | |---|---| |  |  | 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>
…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 | |---|---| |  |  | 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>
…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 | |---|---| |  |  | 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>
<!-- 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. -->
…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 | |---|---| |  |  | 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>

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.
ShellItemRenderernever sets itsUITabBarControllerview'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
PlatformViewin 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 withOpacity < 1are left alone.The earlier WIP attempt (#39893) was flagged for capturing state at
ViewDidLoadbefore custom renderers run and for routing throughUpdateBackground, which can delete externally applied gradient layers. This change avoids both by design: the capture is lazy, and onlyBackgroundColoris ever touched.Tests / evidence
ShellTabSwitchBackgroundTests(iOS device test, Shell category, gated to iOS/Catalyst 18+): builds a two-tab Shell, locates theUITabBarControllerbacking 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), theOpacity < 1exclusion sequence, and a second theory row that registers the handler-based Shell so theShellItemHandlerpath runs too.Before / after (two-tab black sandbox app, iOS 18.5 simulator; both stills are mid-cross-fade frames, the tab labels blended):
Full clips: before.mp4 · after.mp4
Issues Fixed
Fixes #39800