Skip to content

Maui iOS app crashes on startup on real devices: "Attempting to JIT compile method.....while running in aot-only mode" #4131

@drewrobey

Description

@drewrobey

Package

Sentry

.NET Flavor

.NET

.NET Version

9

OS

iOS

OS Version

No response

Development Environment

Visual Studio v17.x

SDK Version

5.5.1

Self-Hosted Sentry Version

No response

Workload Versions

UseSentry or SentrySdk.Init call

.UseSentry(options =>
{
options.Dsn = "REMOVED";

#if DEBUG
options.Debug = true;

                options.TracesSampleRate = 1.0;

#else
options.TracesSampleRate = 0.2;
#endif

                options.IsGlobalModeEnabled = true;
                options.IncludeTextInBreadcrumbs = true;
                options.IncludeTitleInBreadcrumbs = true;
                options.IncludeBackgroundingStateInBreadcrumbs = true;
                options.AttachStacktrace = true;
                options.CaptureFailedRequests = true;
            });

Steps to Reproduce

  1. Create Maui Project
  2. Add Sentry
  3. Build and release for iOS
  4. Install via Testflight on real device
  5. App will crash on startup

Expected Result

App should run.

Actual Result

Here's the exception, which seems to indicate Sentry is trying to JIT-compile something at runtime (via DynamicMethod) on iOS, which is strictly Ahead-Of-Time compiled. iOS forbids runtime JIT, but Android allows it, so the app works on Android and crashes on iOS:

Attempting to JIT compile method '(wrapper dynamic-method) object object:InvokeStub_SafeDigestCtxHandle..ctor (object,object,intptr*)' while running in aot-only mode. See https://learn.microsoft.com/xamarin/ios/internals/limitations

for more information.
(System.ExecutionEngineException)
at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed)
at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type , Object )
at System.Reflection.InvokerEmitUtil.CreateInvokeDelegate_RefArgs(MethodBase , Boolean )
at System.Reflection.MethodInvokerCommon.DetermineStrategy_RefArgs(InvokerStrategy& , InvokeFunc_RefArgs& , MethodBase , Boolean )
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags )
at System.RuntimeType.CreateInstanceMono(Boolean , Boolean )
at System.Activator.CreateInstanceSafeDigestCtxHandle
at System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller`1.ManagedToUnmanagedOut[[System.Security.Cryptography.Apple.SafeDigestCtxHandle, System.Security.Cryptography, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]]..ctor()
at Interop.AppleCrypto.DigestCreate(PAL_HashAlgorithm , Int32& )
at System.Security.Cryptography.LiteHash..ctor(PAL_HashAlgorithm )
at System.Security.Cryptography.HashProviderDispenser.CreateHashProvider(String )
at System.Security.Cryptography.SHA1.Implementation..ctor()
at System.Security.Cryptography.SHA1.Create()
at Sentry.Internal.Extensions.HashExtensions.GetHashString(String , Boolean )
at Sentry.SentryOptions.TryGetDsnSpecificCacheDirectoryPath()
at Sentry.Internal.Http.CachingTransport..ctor(ITransport , SentryOptions , Boolean )
at Sentry.Internal.Http.CachingTransport.Create(ITransport , SentryOptions , Boolean , Boolean )
at Sentry.Internal.SdkComposer.CreateTransport()
at Sentry.Internal.SdkComposer.CreateBackgroundWorker()
at Sentry.SentryClient..ctor(SentryOptions , IBackgroundWorker , RandomValuesFactory , ISessionManager )
at Sentry.Internal.Hub..ctor(SentryOptions , ISentryClient , ISessionManager , ISystemClock , IInternalScopeManager , RandomValuesFactory )
at Sentry.SentrySdk.InitHub(SentryOptions )
at Sentry.SentrySdk.Init(SentryOptions )
at Sentry.Maui.Internal.SentryMauiInitializer.Initialize(IServiceProvider )
at Microsoft.Maui.MauiContextExtensions.InitializeAppServices(MauiApp mauiApp)
at Microsoft.Maui.Hosting.MauiAppBuilder.Build()
at MYPROJECTNAME.MauiProgram.CreateMauiApp()
at MYPROJECTNAME.AppDelegate.CreateMauiApp()
at Microsoft.Maui.MauiUIApplicationDelegate.WillFinishLaunching(UIApplication application, NSDictionary launchOptions)
at Microsoft.Maui.MauiUIApplicationDelegate.Registrar_Callbacks.callback_796_Microsoft_Maui_MauiUIApplicationDelegate_WillFinishLaunching(IntPtr pobj, IntPtr sel, IntPtr p0, IntPtr p1, IntPtr* exception_gchandle)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Done

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions