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:
FATAL EXCEPTION: main
Process: dk.trackman.range.kiosk.virtualgolfmediator, PID: 1976
android.runtime.JavaProxyThrowable: [System.Security.Cryptography.CryptographicException]: Cryptography_ConcurrentUseNotSupported
at System.Security.Cryptography.ConcurrencyBlock.Enter + 0x1a(Unknown Source)
at System.Security.Cryptography.HashProviderDispenser+EvpHashProvider.FinalizeHashAndReset + 0x0(Unknown Source)
at System.Security.Cryptography.HashProvider.FinalizeHashAndReset + 0x13(Unknown Source)
at System.Security.Cryptography.SHA1+Implementation.HashFinal + 0x0(Unknown Source)
at System.Security.Cryptography.HashAlgorithm.CaptureHashCodeAndReinitialize + 0x0(Unknown Source)
at System.Security.Cryptography.HashAlgorithm.ComputeHash + 0x22(Unknown Source)
at Sentry.Internal.Extensions.HashExtensions.GetHashString + 0x12(Unknown Source)
at Sentry.Internal.InstallationIdHelper.TryGetPersistentInstallationId + 0x46(Unknown Source)
at Sentry.Internal.InstallationIdHelper.TryGetInstallationId + 0x3b(Unknown Source)
at Sentry.SentryOptions.<.ctor>b__346_0 + 0x6(Unknown Source)
at System.Lazy`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ViaFactory + 0x44(Unknown Source)
at System.Lazy`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecutionAndPublication + 0x22(Unknown Source)
at System.Lazy`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].CreateValue + 0x74(Unknown Source)
at System.Lazy`1[[System.String, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].get_Value + 0xa(Unknown Source)
at Sentry.SentryOptions.get_InstallationId + 0x0(Unknown Source)
at Sentry.GlobalSessionManager.StartSession + 0x3c(Unknown Source)
at Sentry.Internal.Hub.StartSession + 0x3c(Unknown Source)
at Sentry.Integrations.AutoSessionTrackingIntegration.Register + 0x8(Unknown Source)
at Sentry.Internal.Hub..ctor + 0xf8(Unknown Source)
at Sentry.SentrySdk.InitHub + 0x7d(Unknown Source)
at Sentry.SentrySdk.Init + 0x0(Unknown Source)
at TrackMan.VirtualGolfMediator.Droid.MainApplication.OnCreate + 0x23(Unknown Source)
at Android.App.Application.n_OnCreate + 0x8(Unknown Source)
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V + 0x5(Unknown Source)
at crc6449c06082aa7b0d2b.MainApplication.n_onCreate(Native Method)
at crc6449c06082aa7b0d2b.MainApplication.onCreate(MainApplication.java:24)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
This is when we call the following code in MainApplication.OnCreate:
var options = new SentryLoggingOptions
{
Dsn = "our-dsn-here",
MinimumEventLevel = LogLevel.Critical
};
options.DisableUnobservedTaskExceptionCapture();
SentrySdk.Init(options);
Interestingly we had the IsGlobalModeEnabled = false set in options then it seemd to crash differently at startup with:
FATAL EXCEPTION: main
Process: dk.trackman.range.kiosk.virtualgolfmediator, PID: 2184
android.runtime.JavaProxyThrowable: [System.Threading.LockRecursionException]: LockRecursionException_RecursiveReadNotAllowed
at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore + 0x56(Unknown Source)
at System.Threading.ReaderWriterLockSlim.TryEnterReadLock + 0x0(Unknown Source)
at System.Threading.ReaderWriterLockSlim.TryEnterReadLock + 0x7(Unknown Source)
at System.Threading.ReaderWriterLockSlim.EnterReadLock + 0x0(Unknown Source)
at Sentry.Scope.get_Transaction + 0x0(Unknown Source)
at Sentry.Scope.set_TransactionName + 0x7(Unknown Source)
at Sentry.Scope.Apply + 0x1a8(Unknown Source)
at Sentry.Scope.Apply + 0x9(Unknown Source)
at Sentry.Scope.Clone + 0x1e(Unknown Source)
at Sentry.Internal.SentryScopeManager.PushScope + 0x76(Unknown Source)
at Sentry.Internal.SentryScopeManager.PushScope + 0x0(Unknown Source)
at Sentry.Internal.Hub.PushScope + 0x6(Unknown Source)
at Sentry.Internal.Hub..ctor + 0xc6(Unknown Source)
at Sentry.SentrySdk.InitHub + 0x7d(Unknown Source)
at Sentry.SentrySdk.Init + 0x0(Unknown Source)
at TrackMan.VirtualGolfMediator.Droid.MainApplication.OnCreate + 0x3c(Unknown Source)
at Android.App.Application.n_OnCreate + 0x8(Unknown Source)
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V + 0x5(Unknown Source)
at crc6449c06082aa7b0d2b.MainApplication.n_onCreate(Native Method)
at crc6449c06082aa7b0d2b.MainApplication.onCreate(MainApplication.java:24)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I've managed to narrow this down to the project property AndroidEnableAssemblyCompression which we had set to false. 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.
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=falseset in options then it seemd to crash differently at startup with:I've managed to narrow this down to the project property
AndroidEnableAssemblyCompressionwhich 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.