Repository navigation
[WIP] [iOS] Fix Shell tab switching grey flash on iOS - #39893
Dhivya-SF4094 wants to merge 4 commits into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39893Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39893" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
|
| } | ||
|
|
||
| // UIKit's tab cross-fade exposes this backing view between the two pages. | ||
| view.UpdateBackground(background); |
There was a problem hiding this comment.
[moderate] Backward Compatibility and Migration - On iOS/MacCatalyst 18+, a custom ShellItemRenderer that applies a backing gradient with View.UpdateBackground(gradientPaint) loses it on the next switch to a transparent page. This page is excluded from mirroring, but UpdateBackground(null) still calls RemoveBackgroundLayer() before returning, deleting the custom layer even when OverrideApplied is false. ContentBackgroundState retains only UIColor, so an opaque-page round trip cannot restore that gradient either. Preserve externally supplied background layers and remove only layers owned by this workaround; the new custom-background test covers only solid colors.
| @@ -0,0 +1,295 @@ | |||
| #if IOS | |||
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - #if IOS excludes every new regression test from Mac Catalyst, although both production implementations apply the new backing-background override on Mac Catalyst 18+. Consequently, native-color preservation and displayed-page background/opacity round trips have no coverage on that affected platform. Controls.DeviceTests already includes .iOS.cs files for Catalyst; enable those non-tab-button cases for Catalyst and adjust their iOS-only runtime guards. The documented iOS 26 tab-button limitation does not prevent these direct backing-view assertions.
This comment has been minimized.
This comment has been minimized.
Tests Failure Analysis
🧪 CI Analysis — click to expand📊 maui-prNo failures found. 🧪 maui-pr-devicetestsNo failures found. 🧪 maui-pr-uitests
🧭 Follow-up — actions and refreshNext action: Restore complete UI diagnostics and compare unresolved Mac failures on equivalent target configurations.
|
…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>
…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>
…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>
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Detail:
Switching between Shell’s bottom tabs briefly turns the page background grey, even though every page and its content have a black background. The bottom tab bar remains black. The flash happens during the transition, not after the new page has finished appearing.
Root cause:
On iOS 18+, UIKit applies a fade when UITabBarController.SelectedViewController changes.
During the fade, the page views temporarily become partially transparent, exposing the white tab-controller background underneath. White showing through black produces the visible grey flash.
Description of Change
On iOS 18+ and Mac Catalyst 18+, synchronize the tab controller’s backing-view background with the displayed page’s background using UpdateBackground . This prevents a mismatched backing color from showing during native tab cross-fades, while preserving the native animation.
The method restores the captured native/custom background when its previous override is still present; otherwise, it captures the current background to preserve external customizations. then applies the page background unless the page has reduced opacity or its background is empty or recognized as transparent. It runs when the displayed page changes and when its background or opacity changes.
The fix covers both ShellItemRenderer and ShellItemHandler
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #39800
Screenshots
39800_Beforefix.mov
39800_Afterfix.mov