Skip to content

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

@needledrag

Description

@needledrag

Is there an existing issue for this?

  • I have searched the existing issues

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

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
<Page.Behaviors> <mct:StatusBarBehavior StatusBarColor="{StaticResource AppPrimaryBGColour}" StatusBarStyle="DarkContent"/> </Page.Behaviors>

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

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

Anything else?

Any help or known workaround would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/behaviorsIssue/Discussion/PR that has to do with BehaviorsbugSomething isn't workingnot-reproducedCouldn't reproduce the bugunverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions