-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] CommunityToolkit.Maui.Core.Platform.StatusBar causes app to fail on iOS Testflight #1374
Comments
Hi @needledrag. We have added the "needs reproduction" label to this issue, which indicates that we cannot take further action. This issue will be closed automatically in 5 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@needledrag can you reproduce this using |
Unfortunately not, it all works in release mode and even on a connected device. It's only when I install a published build from App Connect that this occurs. I've even tried to install on the same device that it worked on when testing the release mode and it fails. If all else fails I guess I could change the info.plist and set the Status bar style there directly? |
@needledrag is your app using TabPage or Shell? |
Shell |
@needledrag for now, you can try to set the value on info.plist, probably it's caused by some issue around the initialization. This was working before? |
It works in all other environments and on an Android published app but this is the first time I've published the iOS app to App Connect. |
Verified the issue. Steps to reproduce:
P.S.: Maybe this issue is related to using ReactiveUI for MAUI |
I had to remove the toolkit StatusBarBehavior for iOS builds to get around this |
If you follow the same steps with the sample app do you see the same crash? |
I am experiencing the same thing. Has there been a fix for this yet? |
Verified the issue. Steps to reproduce:
When I try to add the behavior in the xaml.cs instead, it actually gives me a warning saying it's unsupported for iOS and Windows; but the docs are not agreeing. I've included the required info.plist key according to the docs: Works fine for Android and while debugging. But whether it's a Release or Debug build it will not run on the physical iPhone without the debugger attached. |
same here, still not fixed or working with .NET 8 and SimpleToolkit.SimpleShell in my case.
|
I am also getting the error doing this on the constructor on a ContentPage:
Works fine when debugging but it errors when doing an Ad-Hoc build and installing it through iTunes on the device. |
My workaround for this was adding this to the App OnStart()
|
I've had this issue when using the behaviour directly on AppShell.xaml rather than on the ContentPage. To fix that, I've applied the behaviour to the pages rather than shell. |
Experiencing this issue ONLY on the first startup page. Pages that are navigated to from that beginning page are working fine. Odd. |
Even in contentpage on release mode it crashes that is in testflight. Is there any other solution? |
Are you able to upload to testflight without any crash? |
Fixed the status bar issues and was successfully able to build app: |
Noticed this as well in Release mode in iOS, the first page navigation will crash with the attached status bar behavior. Cobbled together this workaround as I only wanted to set the set the color once, it sets the status bar more than once but need something quick that was reliable, This is a MAUI app that doesn't use shell.
|
Thanks @mackayn and @AmaluThomas for sharing your results and workarounds. It is hard for us to reproduce this issue by using the MCT sample app. If we run the sample app on DEBUG or RELEASE mode everything works as expected. However, @needledrag mentioned it only fails when the app is published to TestFlight on iOS. If it is possible from any participant on this issues to share here the Error Stack Trace, maybe from Sentry or Firebase Crashlytics or any other third party error handler service that give us more insights will be fantastic, please. I'm closing this issue for now. We can re-open it if needed in the future. |
I too am hitting this problem in that using the StatusBarBehaviour works as expected in debug but all production builds crash on startup on both Android and iOS. Using a local release build does not have the same problem, it only happens after the build and packaging process. I am using:
The stack trace captured on iOS is as follows: System.NotSupportedException: PlatformSetColor is only supported on iOS and Android 23 and later I note that the exception text comes from StatusBar.net.cs not StatusBar.ios.cs. Could this be a packaging issue? I am not sure why StatusBar.net.cs would be being included on an Android / iOS build. If I copy out the relevant code from StatusBar.Android.cs and StatusBar.ios.cs into my own solution and use that code to change the status bar color then I have no problems. How can I help diagnose this problem? |
Seeing the same issue on opening the first page. Release mode, installed from TestFlight. |
The biggest confusion is still the source of where the exception is thrown in our codebase - it comes from the So to return to an earlier question, where are people using this behavior? Is it in the app project or a class library project? And if it is the latter how is that targeted (e.g. |
@bijington I get this problem in the app project but only if I compile the solution with dotnet 8.0.100. On >= 8.0.400 I no longer have the problem. @ronanj2 what version of dotnet are you compiling your release? |
SDK Version: 8.0.401, GitHub actions hosted runner. |
latter and csproj has:
|
Strange, that fixed it for me |
@ronanj2 are you using toolkit 9.0.3?
|
I had 9.0.2. I just ugpraded to 9.0.3 and same crash happens. |
I can't help but think that this is something that I changed on our build server then as I can see no other code change that would have made a difference. Unfortunately it is offline until when I am back in the office on Tuesday but I will see if I can think of anything when I am back in the office. |
I have the same problem and the application crashes on iOS, even on debug mode using simulator: App.xaml.cs: public partial class App
{
public App()
{
InitializeComponent();
}
protected override Window CreateWindow(IActivationState? activationState)
{
return new(new MainPage());
}
} MainPage.xaml: <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:shared="clr-namespace:MyApplication.Client.Shared;assembly=MyApplication.Client.Shared"
x:Class="MyApplication.Client.Mobile.MainPage"
BackgroundColor="{DynamicResource PageBackgroundColor}">
<ContentPage.Behaviors>
<toolkit:StatusBarBehavior ApplyOn="OnPageNavigatedTo" StatusBarStyle="DarkContent"/>
</ContentPage.Behaviors>
<StackLayout VerticalOptions="FillAndExpand">
<BlazorWebView HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
HostPage="wwwroot/index.html">
<BlazorWebView.RootComponents>
<RootComponent Selector="#app" ComponentType="{x:Type shared:Routes}" />
</BlazorWebView.RootComponents>
</BlazorWebView>
</StackLayout>
</ContentPage> Stacktrace:
Versions:
|
@MoienTajik please note that this issue is closed and we also do not officially support .NET 9.0 and won't until it GAs. |
Previous commentor was .NET 9 but many others (including me) are .NET 8. I posted the TFMs above. |
@ronanj2 the latest crash reported in this comment #1374 (comment) looks like a threading issue on Android and not this issue |
If anyone is still seeing this specific issue we can reopen this. Looking closer at @MoienTajik you can see that the stack trace isn't the same and I believe that issue is related to .NET 9.0 specifics. If anyone can reproduce this issue are you able to provide the CommunityToolkit.Maui.dll binary that will be included in the release folder when building your app? If it isn't in release you might have to grab from the obj folder which might be more tricky in a CI/CD environment. If we could inspect the dll we might be able to ascertain why this is happening. |
Hi all, |
i can confirm this, its getting really annoying that every 2nd or 3rd time when we update our nugets, the ios build gets broken :( |
trust me it is equally frustrating on our side :( Hopefully we may have made a breakthrough based on the linked PR. I think we need to be careful though based on this comment #2243 (comment) |
@TheSundayDev can you provide me with a repro using Toolkit 9.1.0? |
@jfversluis I don't think we are really going to receive a repro for an issue like this. I believe a lot of it is related to environment which will be very difficult to replicate. I believe PR #2243 will help to fix this |
I think we're confusing 2 issues then here because the original issue here talks about the StatusBarBehavior from what it looks like, which I tried to fix here: #2128 Your PR seems to be more about mismatching assembly versions? So... What is the actual issue we're trying to fix or am I not understanding things correctly? |
Oh yeah my bad! I was basing it off this comment #1374 (comment) and some others below it |
I was having the same exception message. |
I did not read all of the comments, but this also causes Android to fail |
Are you sure this is the same issue? All known issues point to it being an iOS specific issue based on our investigations |
If I add the Behavior for Styling the Status Bar, the app fails. I get no errors, just a looping Explicit Concurrent GC |
That's not the same as this issue reports. This issue specifically reports an exception being reported. Can you please raise a separate issue so we can track it? |
Had the same problem (PlatformSetStyle is only supported on iOS and Android 23 and later), downgrade to 9.0.3 was the (temporary) solution! Even had problems with Keyboard extension methods: NotSupportedException on HideKeyboardAsync and ShowKeyboardAsync. |
Is there an existing issue for this?
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:
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
Anything else?
Any help or known workaround would be greatly appreciated.
The text was updated successfully, but these errors were encountered: