CommunityToolkit / CommunityToolkit/Maui

[BUG] CommunityToolkit.Maui.Core.Platform.StatusBar causes app to fail on iOS Testflight

Open
#1,374 64 comments 6 reactions 0 assignees View on GitHub
area/behaviors bug not-reproduced unverified
Dominant language
C#
Stars
2.7k
Forks
500
Avg merge
2d 14h
Merged PRs (30d)
7

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Did you read the "Reporting a bug" section on Contributing file?

- [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

### Current Behavior

I've tested my .net Maui app in Android and iOS, debug, release and on device, Android now in Closed Testing on Google Play.
Just uploaded to App Connect and testing on a device using TestFlight.

On both devices I get the error in appcenter as the app loads the splash screen and goes blank:
```
"exception": {
"type": "System.InvalidOperationException",
"message": "RootViewController cannot be null",
"stackTrace": " at CommunityToolkit.Maui.Core.Platform.StatusBar.UpdateStatusBarAppearance(UIWindow window)\n at CommunityToolkit.Maui.Core.Platform.StatusBar.PlatformSetColor(Color color)\n at CommunityToolkit.Maui.Core.Platform.StatusBar.SetColor(Color color)\n at CommunityToolkit.Maui.Behaviors.StatusBarBehavior.OnPropertyChanged(String propertyName)\n at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)\n at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)\n at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)\n at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value)\n at CommunityToolkit.Maui.Behaviors.StatusBarBehavior.set_StatusBarColor(Color value)\n at InkflowApp.Views.Base.PageBase.InitializeComponent()\n at InkflowApp.Views.Base.PageBase..ctor()\n at InkflowApp.Views.Base.ViewBase`1[[InkflowApp.ViewModels.Home.IntroViewModel, InkflowApp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null]]..ctor()\n at InkflowApp.Views.Home.IntroView..ctor()\n at InkflowApp.ViewModels.Home.InitViewModel.OnNavigatedTo(Object parameters)",
"wrapperSdkName": "appcenter.xamarin"
}
```

I have the following code in my PageBase which every page is based off
`

`

I've read in the MS docs that this should be set in Behaviors as putting it in the class constructor or OnNavigatedTo (or OnAppearing) can cause problems if platform specific components haven't been initialised.

As I mentioned, this works in debug, on device and in release mode for both Android an iOS and published in Android, it just seems to be on publishing the iOS app this occurs every time.

### Expected Behavior

Statusbar colour is set and app proceeds as expected to load the page.

### Steps To Reproduce

As everything works in dev and release you'd need to depoly an app to the App Connect and test in Test Flight as this seems to be the only place I can reproduce it.

### Link to public reproduction project repository

Unable to reproduce except in Test Flight

### Environment

```markdown
- .NET MAUI CommunityToolkit: 5.3
- OS: iOS 14.4.2
- .NET MAUI: 7
```

### Anything else?

Any help or known workaround would be greatly appreciated.

Contributor guide

Open the contributing guide

Research direction

Start with the stack-trace entry points CommunityToolkit.Maui.Core.Platform.StatusBar.UpdateStatusBarAppearance and StatusBarBehavior, then investigate the iOS TestFlight deployment path described in the report. Reproduce the failure in TestFlight if possible; done means the app loads past the splash screen and sets the status bar without the RootViewController exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, ios
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.