-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Initializing SentrySdk Crashes when running with AndroidEnableAssemblyCompression = false in Release mode #3920
Comments
Hey @Cheesebaron, Thanks for raising an issue. I'd avoid setting The original problem you're seeing appears to be coming from here:
Seemingly that
The good news is that I can reproduce with the sample app you provided! And I've found a couple of clues on stack overflow so it should be possible to find a way to work around this. |
I am not even sure why it is only an issue when AndroidEnableAssemblyCompression in csproj is to false. Almost inclined to say it is an issue in the .NET workload. The Global Mode seems to be a misunderstanding from my colleague when setting up Sentry in that App, will let them know 🤔 |
Interestingly, I don't get the problem with the following changes: - var options = new SentryLoggingOptions
+ var options = new SentryOptions
{
- Dsn = "https://[email protected]/5428537",
+ Dsn = "https://[email protected]/5428537"
- MinimumEventLevel = LogLevel.Critical
};
SentrySdk.Init(options); This is odd since the @Cheesebaron is there a reason why you're using |
Sure, in this sample it probably doesn't make sense. The code was extracted from an App where we also call |
I have the same issue as Cheesebaron. Had originally With Options:
It's not the same Exception msg, similar though
|
This issue is very much in the dotnet internals. I've tried various workarounds without success so far. An issue has been filed with the dotnet android team here: dotnet/android#9752 |
I understand this is a .NET bug. But if someone adds our SDK and it crashes, it understandable they won't be happy with Sentry. Looking at the stack trace: Looks like it crashes when we try to start a session:
We should capture this, log with diagnostic logger and carry on. The app wouldn't have session tracking with Sentry but we should at least capture crashes and more importantly. not crash the app. In addition we might have to disable offline caching since we use that to build the path. Although on Android each app has its own folder so shouldn't really need installationId on the path there. sentry-dotnet/src/Sentry/GlobalSessionManager.cs Lines 60 to 95 in f0a778b
In short: we need to degrade the experience, even if we disable Sentry altogether. But we can't crash the app. Even if we silently disable Sentry that's better. |
@bruno-garcia We currently don't have a way of detecting that this issue is coming. We've discussed being able to source gen over some of the build contextual information such as this android flag. The issue is far deeper in decrypting the installationID. IF I try/catch the issue at the level it is at (or even up a couple of calls in the stack), the issue begins to balloon out from there. I tried to find a suitable workaround or notification without too much success. In terms of timeboxing a resolution to this issue, and instead of overcomplicating the Sentry SDK (and likely causing other downstream issues), we decided the best course of action was to document this for now. We haven't done the doc on it yet since we've been busy with other things. We can pin this issue in the meantime? |
For posterity, here is one reason why people might want to set this value to false. @Cheesebaron is this why you're doing it or did you have some other reason? |
No we had it as there was a bug in an earlier version of net-android which crashed at startup failing to extract assemblies on some devices. This was fixed later. I think this was around .NET 7 |
OK that makes it easier to workaround then - for the most part people should be able to avoid having to set this to Still, if there's any way we could degrade functionality and log (rather than crash), in these situations, that would be preferable. @aritchie let's discuss next time we catch up. |
Package
Sentry.Extensions.Logging
.NET Flavor
.NET
.NET Version
9.0.100
OS
Android
SDK Version
5.0.0 + 5.0.1
Self-Hosted Sentry Version
No response
Steps to Reproduce
We have an application which only exposes a Service. This is normally bound to by some of our other applications to exchange information.
We upgraded to .NET 9 and Sentry to 5.0.1 recently, and we see a weird crash when the Service starts, we initially thought it was some of our dependencies that were causing the issue, but seems like even when moving the initialization code to MainApplication it throws the following exception at startup:
This is when we call the following code in
MainApplication.OnCreate
:Interestingly we had the
IsGlobalModeEnabled
=false
set in options then it seemd to crash differently at startup with:I've managed to narrow this down to the project property
AndroidEnableAssemblyCompression
which we had set tofalse
. If I recall correctly, we set this to work around an issue in an earlier version of the .NET Android workloads that would crash the App at startup trying to unpack the assemblies.My question is, why does this cause Sentry to crash at startup when this property is set to false. Seemingly it mainly happens in Sentry code, because when we remove SentrySdk.Init the rest of the App seems to work OK.
Here is a repo with the issue: https://github.com/Cheesebaron/SentryInitCrash build it in Release mode and deploy to an emulator/device and start the main activity. It will crash on startup with a similar error as above.
Expected Result
SentrySdk.Init should with with
AndroidEnableAssemblyCompression
=false
?Actual Result
See exceptions above.
The text was updated successfully, but these errors were encountered: