Skip to content

Unhandled crashes are not been reported in release mode on iOS apps #4012

Closed

Description

@mackayn

Package

Sentry.Maui

.NET Flavor

.NET

.NET Version

9.0.200

OS

iOS

SDK Version

5.2.0

Self-Hosted Sentry Version

No response

Steps to Reproduce

Setup Sentry in builder

		builder
			.UseMauiApp<App>()
			.UseSentry(options => {
				options.Dsn = "DSN";
#if DEBUG
        options.Debug = true;
        options.TracesSampleRate = 1.0;
#endif
				options.IsGlobalModeEnabled = true;
				options.StackTraceMode = StackTraceMode.Enhanced;
			})

iOS Release config

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0-ios|AnyCPU'">
    <CodesignProvision>Automatic</CodesignProvision>
    <CodesignKey>iPhone Distribution</CodesignKey>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
    <ProvisioningType>manual</ProvisioningType>
    <UseInterpreter>false</UseInterpreter>
    <MtouchLink>SdkOnly</MtouchLink>
    <ArchiveOnBuild>true</ArchiveOnBuild>
    <BuildIpa>True</BuildIpa>
    <IsAotCompatible>true</IsAotCompatible>
    <PublishAot>true</PublishAot>
  </PropertyGroup>

Expected Result

Unhandled exceptions in debug profile are caught and shown in the sentry dashboard for the iOS .NET9 MAUI (9.0.40) app (AOT compiled, doesn't work either is not AOT compiled).

In release mode, unhandled exceptions is captured.

Actual Result

Unhandled exceptions in debug profile are caught and shown in the sentry dashboard for the .NET9 MAUI (9.0.40) app.

In release mode, nothing is captured on unhandled exceptions making it very difficult to diagnose crashes since porting to .NET9.

Is there a way to manually add debug symbols like you could with AppCenter, in this case the builds are not generated via a pipeline.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 28, 2025
  2. bruno-garcia commented on Feb 28, 2025

    @bruno-garcia
    Member

    In release mode, nothing is captured on unhandled exceptions making it very difficult to diagnose crashes since porting to .NET9.

    Do you have any logs of the sdk you can share? you can turn it on with Debug=true and get them from the mac console streaming ur phones logs.

    also if you have a link to your Sentry project I can see if there's data ben dropped. You can see that too under Stats in the left nav bar

    Is there a way to manually add debug symbols like you could with AppCenter, in this case the builds are not generated via a pipeline.

    sentry can upload during msbuild build (https://docs.sentry.io/platforms/dotnet/configuration/msbuild/ ) but if you want to upload outside of msbuild you can with our CLI (which is what we use under the hood from the sdk too): https://docs.sentry.io/platforms/apple/dsym/

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Feb 28, 2025
  4. mackayn commented on Feb 28, 2025

    @mackayn
    Author

    In release mode, nothing is captured on unhandled exceptions making it very difficult to diagnose crashes since porting to .NET9.

    Do you have any logs of the sdk you can share? you can turn it on with Debug=true and get them from the mac console streaming ur phones logs.

    also if you have a link to your Sentry project I can see if there's data ben dropped. You can see that too under Stats in the left nav bar

    Is there a way to manually add debug symbols like you could with AppCenter, in this case the builds are not generated via a pipeline.

    sentry can upload during msbuild build (https://docs.sentry.io/platforms/dotnet/configuration/msbuild/ ) but if you want to upload outside of msbuild you can with our CLI (which is what we use under the hood from the sdk too): https://docs.sentry.io/platforms/apple/dsym/

    I can't share the URL here but do you have a mailbox I can send the URL's to ?
    There is data in stats but as mentioned, it's only debug crashes with a debugger attached

    thanks for the link for the symbols but a bit of a clunky process if your a VS2022 Windows users and you have to look for the build manually on the mac host

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Feb 28, 2025
  6. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 1, 2025
  7. jamescrosswell commented on Mar 3, 2025

    @jamescrosswell
    Collaborator

    thanks for the link for the symbols but a bit of a clunky process if your a VS2022 Windows users and you have to look for the build manually on the mac host

    If you're doing it via MS Build, the transitive build file should run all the necessary CLI commands for you from wherever the build is running... and you should get logs of all that happening in your Debug window as the build occurs. That experience should be pretty similar to what it would feel like to do this directly on a Mac using Jetbrains Rider or the command line.

    If you want to run the CLI commands yourself manually then yes, using a remote Mac will make it a bit more painful. But then everything is a bit more painful when you try to build iOS apps from Windows. That's basically a consequence of the requirement to use Xcode to build iOS apps (so not specific to Sentry).

  8. mackayn commented on Mar 3, 2025

    @mackayn
    Author

    thanks for the link for the symbols but a bit of a clunky process if your a VS2022 Windows users and you have to look for the build manually on the mac host

    If you're doing it via MS Build, the transitive build file should run all the necessary CLI commands for you from wherever the build is running... and you should get logs of all that happening in your Debug window as the build occurs. That experience should be pretty similar to what it would feel like to do this directly on a Mac using Jetbrains Rider or the command line.

    If you want to run the CLI commands yourself manually then yes, using a remote Mac will make it a bit more painful. But then everything is a bit more painful when you try to build iOS apps from Windows. That's basically a consequence of the requirement to use Xcode to build iOS apps (so not specific to Sentry).

    That's not particularly helpful. It doesn't explain why unhandled crashes (race condition I suspect as it was ok in .NET8 release mode) aren't caught but they are in debug build config, we need to have confidence it does that basics before we can release the apps.

  9. 18 remaining items

  10. jamescrosswell commented on Mar 5, 2025

    @jamescrosswell
    Collaborator

    The trouble is that UnhandledExceptionHandler does not always fire on MAUI.

    See here:

    The UnhandledException hook isn't fired when using CoreCLR (on macOS or when using NativeAOT)... which is why we're using Runtime.MarshalManagedException.

    Apparently @mackayn has found a scenario where Runtime.MarshalManagedException isn't firing either though. I haven't had a chance to dig into this yet or reproduce/confirm the issue.

    @mackayn have you made any progress understanding where the crashes are coming from and how we might reproduce this? Simple scenarios like the unhandled crashes caused by our sample app are captured by Sentry, so we need to work out what's happening in your scenario that's not happening in the context of that sample app to be able to reproduce and resolve the issue.

  11. mackayn commented on Mar 6, 2025

    @mackayn
    Author

    The trouble is that UnhandledExceptionHandler does not always fire on MAUI.

    See here:

    The UnhandledException hook isn't fired when using CoreCLR (on macOS or when using NativeAOT)... which is why we're using Runtime.MarshalManagedException.

    Apparently @mackayn has found a scenario where Runtime.MarshalManagedException isn't firing either though. I haven't had a chance to dig into this yet or reproduce/confirm the issue.

    @mackayn have you made any progress understanding where the crashes are coming from and how we might reproduce this? Simple scenarios like the unhandled crashes caused by our sample app are captured by Sentry, so we need to work out what's happening in your scenario that's not happening in the context of that sample app to be able to reproduce and resolve the issue.

    No, as mentioned, the crash was low level. Identical C# code that worked in .NET8 was crashing the app in .NET9, compiling with the interpreter enabled in iOS solves the issue, something was been stripped out. It's worth mentioning that the crash occurred whether compiling with or without AOT compilation. We're only trimming the Sdk (SdkOnly).

    System.NotSupportedException
    ConstructorContainsNullParameterNames, System.Collections.Generic.KeyValuePair`2[System.String,System.Boolean]
    

    Having looked at macios/#15252, If this is a .NET issue and not a Sentry issue, I am happy for this to be closed, oddly UnhandledExceptionHandler helped me get a clue, maybe on that test I'd compiled with AOT disabled but from reading the macOS issue, maybe it's not a great idea to hook it up as we're using AOT compilation in iOS now as it improves app startup performance.

  12. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Mar 6, 2025
  13. bruno-garcia commented on Mar 7, 2025

    @bruno-garcia
    Member

    Even with this being a dotnet issue we could keep this ticket open and try to find a work around. such as using FirstChanceException and letting some types of errors through, for example.

  14. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 7, 2025
  15. jamescrosswell commented on Apr 1, 2025

    @jamescrosswell
    Collaborator

    Even with this being a dotnet issue we could keep this ticket open and try to find a work around. such as using FirstChanceException and letting some types of errors through, for example.

    Without being able to reproduce the original problem, I can't see too much more we can do with this. I can't see any meaningful way to use the FirstChanceException.

    Closing for now then. @mackayn if you're able to provide a reproducible example then we can dig into it further.

  16. mackayn commented on Apr 1, 2025

    @mackayn
    Author

    @jamescrosswell Fair enough but probably have to stop using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions