dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

.NET MAUI App Crashes in Release Mode but works fine in debug mode. #24178

Closed vsfeedback closed 3 months ago

vsfeedback commented 3 months ago

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] This is our school project in .NET MAUI, and we encountered a problem that if we try to run the app in release mode for all platforms including android, windows, and iOS, it crashes when the buttons are clicked. And because of this, we cannot publish it.

Here is our GitHub Repository: https://github.com/SeesonLau/ProjectMentorMatch

Please help us as to find any workaround as the deadline is near. Thank you very much.


Original Comments

Feedback Bot on 7/14/2024, 09:50 PM:

(private comment, text removed)

YanFang Wang (CSI Interfusion Inc) [MSFT] on 7/15/2024, 05:13 AM:

(private comment, text removed)

Lord Kent Dinampo on 7/16/2024, 00:59 AM:

(private comment, text removed)

YanFang Wang (CSI Interfusion Inc) [MSFT] on 7/17/2024, 01:12 AM:

(private comment, text removed)


Original Solutions

(no solutions)

github-actions[bot] commented 3 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

sumowesley commented 3 months ago

/I'm experiencing something similar. I've had the application running in Debug on Windows 11, the Android Simulator (Pixel 8 on API 34), the iOS simulator (iOS 17.0, iPhone 14 Pro), and Mac-Catalyst (Sonoma 14.6.1).

Today I compiled to an IPA file and submitted to App Store Connect using Transporter. Deploying to my iPhone (which had run fine in Debug mode from VS Code on the Mac) crashed. I loaded up Visual Studio on the PC, connected it to my Mac, and deployed several Release versions before finding the cause of the crash; it crashed in the same place as the version deployed from TestFLight. The use of Automapper was the problem. Reading other issues, using UseInterpreter as True was suggested when using System.Reflection. Deploying to the iPhone from Visual Studio lets me run the code that uses Automapper.

Creating a new release in TestFlight base on using the interpreter now causes it to crash immediately when deployed on iOS.

Regrettably, my attempts to rectify the issue were unsuccessful. Despite creating a new IPA file and submitting it to App Store Connect, the app continued to malfunction. Instead of crashing a few screens into the app, as it did previously, it now crashes immediately upon startup.

My method of creating a Release mode app on the iPhone from Visual Studio is no longer available as an investigative aid as the code runs as expected. I'll add the crash log below.

I would appreciate any suggestions.

sumowesley commented 3 months ago

Crash log contents

Incident Identifier: 42E8F851-E406-4677-9F20-D4B1E01ECCE6 Distributor ID: com.apple.TestFlight Hardware Model: iPhone16,1 Process: CaseyApp [5321] Path: /private/var/containers/Bundle/Application/675CF61C-7FB1-4783-95C5-586F7D3BADA5/CaseyApp.app/CaseyApp Identifier: uk.co.fivesixsolutions.caseyapp Version: 1.0 (14) AppStoreTools: 15F31e AppVariant: 1:iPhone16,1:17.4 Beta: YES Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: uk.co.fivesixsolutions.caseyapp [1470]

Date/Time: 2024-08-13 19:59:53.2604 +0100 Launch Time: 2024-08-13 19:59:53.0485 +0100 OS Version: iPhone OS 17.6.1 (21G93) Release Type: User Baseband Version: 1.70.02 Report Version: 104

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: SIGNAL 6 Abort trap: 6 Terminating Process: CaseyApp [5321]

Triggered by Thread: 0

Kernel Triage: VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter

Thread 0 name: Thread 0 name: Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001dcd842ec __pthread_kill + 8 (:-1) 1 libsystem_pthread.dylib 0x00000001f0b77c0c pthread_kill + 268 (pthread.c:1721) 2 libsystem_c.dylib 0x000000019c083ba0 abort + 180 (abort.c:118) 3 CaseyApp 0x0000000102d97020 0x102a60000 + 3371040 4 CaseyApp 0x0000000102d04628 0x102a60000 + 2770472 5 libsystem_platform.dylib 0x00000001f0abae9c _sigtramp + 56 (sigtramp.c:116) 6 libsystem_pthread.dylib 0x00000001f0b77c0c pthread_kill + 268 (pthread.c:1721) 7 libsystem_c.dylib 0x000000019c083ba0 abort + 180 (abort.c:118) 8 CaseyApp 0x0000000102a8fa80 0x102a60000 + 195200 9 CaseyApp 0x0000000102c403d4 0x102a60000 + 1967060 10 CaseyApp 0x0000000102cdadc4 0x102a60000 + 2600388 11 CaseyApp 0x0000000102a97fdc 0x102a60000 + 229340 12 CaseyApp 0x0000000102d42d3c 0x102a60000 + 3026236 13 dyld 0x00000001b78cb154 start + 2356 (dyldMain.cpp:1298)

Thread 1: 0 libsystem_pthread.dylib 0x00000001f0b710c4 start_wqthread + 0 (:-1)

Thread 2 name: Thread 2: 0 libsystem_kernel.dylib 0x00000001dcd7f08c __psynch_cvwait + 8 (:-1) 1 libsystem_pthread.dylib 0x00000001f0b736e4 _pthread_cond_wait + 1228 (pthread_cond.c:862) 2 CaseyApp 0x0000000102c1b204 0x102a60000 + 1815044 3 libsystem_pthread.dylib 0x00000001f0b7606c _pthread_start + 136 (pthread.c:931) 4 libsystem_pthread.dylib 0x00000001f0b710d8 thread_start + 8 (:-1)

Thread 3 name: Thread 3: 0 libsystem_kernel.dylib 0x00000001dcd79644 semaphore_wait_trap + 8 (:-1) 1 CaseyApp 0x0000000102cb619c 0x102a60000 + 2449820 2 CaseyApp 0x0000000102c9398c 0x102a60000 + 2308492 3 libsystem_pthread.dylib 0x00000001f0b7606c _pthread_start + 136 (pthread.c:931) 4 libsystem_pthread.dylib 0x00000001f0b710d8 thread_start + 8 (:-1)

Thread 4: 0 libsystem_pthread.dylib 0x00000001f0b710c4 start_wqthread + 0 (:-1)

Thread 5: 0 libsystem_pthread.dylib 0x00000001f0b710c4 start_wqthread + 0 (:-1)

Thread 6: 0 libsystem_pthread.dylib 0x00000001f0b710c4 start_wqthread + 0 (:-1)

Thread 7: 0 libsystem_pthread.dylib 0x00000001f0b710c4 start_wqthread + 0 (:-1)

Thread 8: 0 libsystem_pthread.dylib 0x00000001f0b710c4 start_wqthread + 0 (:-1)

Thread 9: 0 libsystem_pthread.dylib 0x00000001f0b710c4 start_wqthread + 0 (:-1)

Thread 10 name: Thread 10: 0 libsystem_kernel.dylib 0x00000001dcd796c8 mach_msg2_trap + 8 (:-1) 1 libsystem_kernel.dylib 0x00000001dcd7cec8 mach_msg2_internal + 80 (mach_msg.c:201) 2 libsystem_kernel.dylib 0x00000001dcd7cde0 mach_msg_overwrite + 436 (mach_msg.c:0) 3 libsystem_kernel.dylib 0x00000001dcd7cc20 mach_msg + 24 (mach_msg.c:323) 4 CoreFoundation 0x00000001940f4f5c CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2624) 5 CoreFoundation 0x00000001940f4600 CFRunLoopRun + 1208 (CFRunLoop.c:3007) 6 CoreFoundation 0x00000001940f3cd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420) 7 Foundation 0x0000000193014b5c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373) 8 Foundation 0x00000001930149ac -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420) 9 UIKitCore 0x000000019674181c -[UIEventFetcher threadMain] + 420 (UIEventFetcher.m:1207) 10 Foundation 0x000000019302b428 NSThreadstart__ + 732 (NSThread.m:991) 11 libsystem_pthread.dylib 0x00000001f0b7606c _pthread_start + 136 (pthread.c:931) 12 libsystem_pthread.dylib 0x00000001f0b710d8 thread_start + 8 (:-1)

Thread 0 crashed with ARM Thread State (64-bit): x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000000000000 x4: 0xffffffff95a8cacd x5: 0x0000000000000018 x6: 0x000000016d39ed50 x7: 0x000000016d39e440 x8: 0xa73eefe4b47a978d x9: 0xa73eefe540d9294d x10: 0x0000000000000200 x11: 0x000000016d39e4b0 x12: 0x0000000000000000 x13: 0x0000000102a8cd04 x14: 0x0000000000000010 x15: 0x0000000000000000 x16: 0x0000000000000148 x17: 0x00000001f4a3bec0 x18: 0x0000000000000000 x19: 0x0000000000000006 x20: 0x0000000000000103 x21: 0x00000001f4a3bfa0 x22: 0x000000015881f600 x23: 0x0000000000000001 x24: 0x0000000301941680 x25: 0x0000000000000000 x26: 0x0000000000000000 x27: 0x000000016d39fc65 x28: 0x0000000300f44540 fp: 0x000000016d39ed60 lr: 0x00000001f0b77c0c sp: 0x000000016d39ed40 pc: 0x00000001dcd842ec cpsr: 0x40001000 esr: 0x56000080 Address size fault

Binary Images: 0x102a60000 - 0x102e4ffff CaseyApp arm64 <7e4d50540cce34169def87e98ae1477e> /private/var/containers/Bundle/Application/675CF61C-7FB1-4783-95C5-586F7D3BADA5/CaseyApp.app/CaseyApp 0x103b54000 - 0x10402bfff realm-wrappers arm64 /private/var/containers/Bundle/Application/675CF61C-7FB1-4783-95C5-586F7D3BADA5/CaseyApp.app/Frameworks/realm-wrappers.framework/realm-wrappers 0x105c08000 - 0x105c13fff libobjc-trampolines.dylib arm64e /private/preboot/Cryptexes/OS/usr/lib/libobjc-trampolines.dylib 0x192f4d000 - 0x193ac2fff Foundation arm64e /System/Library/Frameworks/Foundation.framework/Foundation 0x1940a1000 - 0x1945cefff CoreFoundation arm64e <76a3b1983c09323e83590d4978e156f5> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 0x196323000 - 0x197e44fff UIKitCore arm64e <9da0d27355063712b73de0149d74c13c> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore 0x19c00e000 - 0x19c08bff3 libsystem_c.dylib arm64e <7135c2c8ba5836368b46a9e6226ead45> /usr/lib/system/libsystem_c.dylib 0x1b788e000 - 0x1b791b937 dyld arm64e <52039c944da13638bd52020a0b5fa399> /usr/lib/dyld 0x1dcd78000 - 0x1dcdb1fef libsystem_kernel.dylib arm64e <21ee5290d1193c31b948431865a67738> /usr/lib/system/libsystem_kernel.dylib 0x1f0aba000 - 0x1f0ac0ff3 libsystem_platform.dylib arm64e <4b4e9e322e40357899c1cd1c907b8ce5> /usr/lib/system/libsystem_platform.dylib 0x1f0b70000 - 0x1f0b7cff3 libsystem_pthread.dylib arm64e /usr/lib/system/libsystem_pthread.dylib

EOF

drasticactions commented 3 months ago

@sumowesley Release mode for MAUI iOS/Catalyst turns the Mono Interpreter off. It's enabled by default for Debug MAUI UI applications. This is referenced in the documentation.

https://learn.microsoft.com/en-us/dotnet/maui/macios/interpreter?view=net-maui-8.0#enable-the-interpreter

If you enable the interpreter for Release mode, your app should work again. If you don't wish to enable the interpreter, then you will need to refactor your code to remove code that does not play well with AOT, including AutoMapper.

@rolfbjarne is this correct?

sumowesley commented 3 months ago

@sumowesley Release mode for MAUI iOS/Catalyst turns the Mono Interpreter off. It's enabled by default for Debug MAUI UI applications. This is referenced in the documentation.

https://learn.microsoft.com/en-us/dotnet/maui/macios/interpreter?view=net-maui-8.0#enable-the-interpreter

If you enable the interpreter for Release mode, your app should work again. If you don't wish to enable the interpreter, then you will need to refactor your code to remove code that does not play well with AOT, including AutoMapper.

@rolfbjarne is this correct?

@drasticactions , I'm already using the interpreter as True. That's what got it to work in Release mode when the phone was tethered to my Mac, while using Visual Studio on Windows to deploy onto the phone. Here's the PropertyGroup from my .csproj:

  <PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
    <UseInterpreter>True</UseInterpreter>
  </PropertyGroup>

My original post had the UseInterpreter in angle brackets and it didn't show - I've amended it accordingly to reflect the current position.

rolfbjarne commented 3 months ago

There might be something other than the (no longer absent) interpreter in Release mode causing the crash.

The important part is to figure out exactly what, and I would:

  1. Stop stripping native symbols; this will make any crash reports (like the one above show better stack traces.
  2. Look at the device log to see if anything is printed there.
sumowesley commented 3 months ago

Hi @rolfbjarne, I started on a similar path early this morning. Given that the code operates as I'd expect in Release mode when the App is added directly (VS Code or Visual Studio connected to the Mac), the only option was to make changes and send a new IPA file to App Store Connect and then use TestFlight to download each version. Steps taken:

I can't explain why it's now working. The bin and obj directories on my Mac were removed at some point, but I'm certain it was before I'd done the AutoMapper sequence.

Thank you for the symbols suggestion; I'll add the command line option to my IPA generation script.

mnxamdev commented 3 months ago

We're having this issue on Android as well OS 13 and up. We had this come up last month probably after a MAUI update but then I disabled AOT in my Android build and builds went fine. Now are Android builds are back to crashing on start.

<RunAOTCompilation>False</RunAOTCompilation>
r-work commented 3 months ago

Have the same issue here, ios works fine while debugging, it crashes on startup in testflight. And here is the crash log (though can't make head or tail of it):

Incident Identifier: 75A4EA77-91D5-413E-BAFB-45B0DA3EC680
Beta Identifier:     D7B909AE-1DC4-53CA-9446-9EE1831290E9
Hardware Model:      Macmini9,1
Process:             MyApp.Mobile [671]
Path:                /Volumes/VOLUME/*/MyApp.Mobile.app/MyApp.Mobile
Identifier:          co.uk.MyApp
Version:             1.0.4871 (1.0.4871)
AppStoreTools:       15F31e
AppVariant:          1:MacFamily20,1:17.4
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           co.uk.MyApp [859]

Date/Time:           2024-08-15 10:16:08.7906 +0100
Launch Time:         2024-08-15 10:16:05.8727 +0100
OS Version:          macOS 14.6.1 (23G93)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000019d6a3758
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [671]

Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                         0x199bde2e0 __exceptionPreprocess + 164
1   libobjc.A.dylib                        0x1996c2158 objc_exception_throw + 60
2   MyApp.Mobile                           0x1005ceca0 xamarin_unhandled_exception_handler + 0 (runtime.m:1128)
3   MyApp.Mobile                           0x10092d184 native_to_managed_trampoline_3(objc_object*, objc_selector*, _MonoMethod**, objc_object*, objc_object*, unsigned int) + 864 (registrar.mm:190)
4   MyApp.Mobile                           0x10092d204 -[Microsoft_Maui_MauiUIApplicationDelegate application:didFinishLaunchingWithOptions:] + 64 (registrar.mm:10131)
5   UIKitCore                              0x1c9045b70 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 316
6   UIKitCore                              0x1c9045030 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 2832
7   UIKitCore                              0x1c9043318 -[UIApplication _runWithMainScene:transitionContext:completion:] + 988
8   UIKitCore                              0x1c9042e4c -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 108
9   UIKitCore                              0x1c903f934 _UIScenePerformActionsWithLifecycleActionMask + 112
10  UIKitCore                              0x1c9042798 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 216
11  UIKitCore                              0x1c904251c -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 332
12  UIKitCore                              0x1c9041a78 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 608
13  UIKitCore                              0x1c9041774 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 248
14  UIKitCore                              0x1c903ff10 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 148
15  UIKitCore                              0x1c989c06c +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 736
16  UIKitCore                              0x1c998ed24 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 224
17  UIKitCore                              0x1c903fabc -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 316
18  UIKitCore                              0x1c935c7d8 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.243 + 612
19  UIKitCore                              0x1c903ef58 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 216
20  UIKitCore                              0x1c903edc8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 244
21  UIKitCore                              0x1c9034ad0 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 508
22  UIKitCore                              0x1c903485c -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 288
23  FrontBoardServices                     0x1af691ad8 -[FBSScene _callOutQueue_didCreateWithTransitionContext:completion:] + 340
24  FrontBoardServices                     0x1af6ba284 __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke.139 + 284
25  FrontBoardServices                     0x1af67c048 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 196
26  FrontBoardServices                     0x1af6b9f98 __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke + 348
27  libdispatch.dylib                      0x1998d93e8 _dispatch_client_callout + 20
28  libdispatch.dylib                      0x1998dce80 _dispatch_block_invoke_direct + 288
29  FrontBoardServices                     0x1af67bf5c __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48
30  FrontBoardServices                     0x1af6da0b4 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240
31  FrontBoardServices                     0x1af6da1e8 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28
32  CoreFoundation                         0x199b694d8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
33  CoreFoundation                         0x199b6946c __CFRunLoopDoSource0 + 176
34  CoreFoundation                         0x199b691dc __CFRunLoopDoSources0 + 244
35  CoreFoundation                         0x199b67dc8 __CFRunLoopRun + 828
36  CoreFoundation                         0x199b67434 CFRunLoopRunSpecific + 608
37  HIToolbox                              0x1a431119c RunCurrentEventLoopInMode + 292
38  HIToolbox                              0x1a4310e2c ReceiveNextEventCommon + 220
39  HIToolbox                              0x1a4310d30 _BlockUntilNextEventMatchingListInModeWithFilter + 76
40  AppKit                                 0x19d3c6cc8 _DPSNextEvent + 660
41  AppKit                                 0x19dbbd4d0 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
42  AppKit                                 0x19d3b9ffc -[NSApplication run] + 476
43  AppKit                                 0x19d391240 NSApplicationMain + 880
44  AppKit                                 0x19d5e4654 +[NSWindow _savedFrameFromString:] + 0
45  UIKitMacHelper                         0x1b2e45f50 UINSApplicationMain + 972
46  UIKitCore                              0x1c901d7bc UIApplicationMain + 148
47  MyApp.Mobile                           0x1005cc1d0 xamarin_UIApplicationMain + 24 (bindings.m:131)
48  MyApp.Mobile                           0x1008fee2c do_icall + 316 (interp.c:2310)
49  MyApp.Mobile                           0x1008fd72c do_icall_wrapper + 348 (interp.c:2351)
50  MyApp.Mobile                           0x1008f213c mono_interp_exec_method + 2836
51  MyApp.Mobile                           0x1008efcd4 interp_runtime_invoke + 236 (interp.c:2110)
52  MyApp.Mobile                           0x1008be9e0 mono_jit_runtime_invoke + 1116 (mini-runtime.c:3673)
53  MyApp.Mobile                           0x100866124 do_runtime_invoke + 60 (object.c:2576) [inlined]
54  MyApp.Mobile                           0x100866124 mono_runtime_invoke_checked + 148 (object.c:2792)
55  MyApp.Mobile                           0x10086c420 do_exec_main_checked + 60 [inlined]
56  MyApp.Mobile                           0x10086c420 mono_runtime_exec_main_checked + 116 (object.c:4775)
57  MyApp.Mobile                           0x1008c3f80 mono_jit_exec_internal + 16 (driver.c:1369) [inlined]
58  MyApp.Mobile                           0x1008c3f80 mono_jit_exec + 356 (driver.c:1314)
59  MyApp.Mobile                           0x1005d72ac xamarin_main + 956
60  MyApp.Mobile                           0x10092c6ac main + 64 (main.arm64.mm:87)
61  dyld                                   0x1996ff154 start + 2476

Thread 0 Crashed:: tid_103 Dispatch queue: com.apple.main-thread
0   AppKit                                 0x19d6a3758 -[NSApplication _crashOnException:] + 240
1   AppKit                                 0x19d6a3530 -[NSApplication reportException:] + 440
2   AppKit                                 0x19d8081d4 NSApplicationUncaughtExceptionHandler + 152
3   CoreFoundation                         0x199c83024 __handleUncaughtException + 800
4   libobjc.A.dylib                        0x1996cbbe4 _objc_terminate() + 132
5   libc++abi.dylib                        0x199a400cc std::__terminate(void (*)()) + 16
6   libc++abi.dylib                        0x199a40070 std::terminate() + 108
7   libdispatch.dylib                      0x1998d93fc _dispatch_client_callout + 40
8   libdispatch.dylib                      0x1998dce80 _dispatch_block_invoke_direct + 288
9   FrontBoardServices                     0x1af67bf5c __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48
10  FrontBoardServices                     0x1af6da0b4 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240
11  FrontBoardServices                     0x1af6da1e8 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28
12  CoreFoundation                         0x199b694d8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
13  CoreFoundation                         0x199b6946c __CFRunLoopDoSource0 + 176
14  CoreFoundation                         0x199b691dc __CFRunLoopDoSources0 + 244
15  CoreFoundation                         0x199b67dc8 __CFRunLoopRun + 828
16  CoreFoundation                         0x199b67434 CFRunLoopRunSpecific + 608
17  HIToolbox                              0x1a431119c RunCurrentEventLoopInMode + 292
18  HIToolbox                              0x1a4310e2c ReceiveNextEventCommon + 220
19  HIToolbox                              0x1a4310d30 _BlockUntilNextEventMatchingListInModeWithFilter + 76
20  AppKit                                 0x19d3c6cc8 _DPSNextEvent + 660
21  AppKit                                 0x19dbbd4d0 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
22  AppKit                                 0x19d3b9ffc -[NSApplication run] + 476
23  AppKit                                 0x19d391240 NSApplicationMain + 880
24  AppKit                                 0x19d5e4654 _NSApplicationMainWithInfoDictionary + 24
25  UIKitMacHelper                         0x1b2e45f50 UINSApplicationMain + 972
26  UIKitCore                              0x1c901d7bc UIApplicationMain + 148
27  MyApp.Mobile                           0x1005cc1d0 xamarin_UIApplicationMain + 24 (bindings.m:126)
28  MyApp.Mobile                           0x1008fee2c do_icall + 316 (interp.c:2310)
29  MyApp.Mobile                           0x1008fd72c do_icall_wrapper + 348 (interp.c:2350)
30  MyApp.Mobile                           0x1008f213c mono_interp_exec_method + 2836
31  MyApp.Mobile                           0x1008efcd4 interp_runtime_invoke + 236 (interp.c:2109)
32  MyApp.Mobile                           0x1008be9e0 mono_jit_runtime_invoke + 1116 (mini-runtime.c:3672)
33  MyApp.Mobile                           0x100866124 do_runtime_invoke + 60 (object.c:2576) [inlined]
34  MyApp.Mobile                           0x100866124 mono_runtime_invoke_checked + 148 (object.c:2792)
35  MyApp.Mobile                           0x10086c420 do_exec_main_checked + 60 [inlined]
36  MyApp.Mobile                           0x10086c420 mono_runtime_exec_main_checked + 116 (object.c:4775)
37  MyApp.Mobile                           0x1008c3f80 mono_jit_exec_internal + 16 (driver.c:1369) [inlined]
38  MyApp.Mobile                           0x1008c3f80 mono_jit_exec + 356 (driver.c:1314)
39  MyApp.Mobile                           0x1005d72ac xamarin_main + 956 (monotouch-main.m:495)
40  MyApp.Mobile                           0x10092c6ac main + 64 (main.arm64.mm:87)
41  dyld                                   0x1996ff154 start + 2476

Thread 1:
0   libsystem_pthread.dylib                0x199a84d20 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib                0x199a84d20 start_wqthread + 0

Thread 3:: SGen worker
0   libsystem_kernel.dylib                 0x199a4c5ec __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x199a8a55c _pthread_cond_wait + 1228
2   MyApp.Mobile                           0x1007fe528 mono_os_cond_wait + 8 (mono-os-mutex.h:219) [inlined]
3   MyApp.Mobile                           0x1007fe528 get_work + 228 (sgen-thread-pool.c:164) [inlined]
4   MyApp.Mobile                           0x1007fe528 thread_func + 440 (sgen-thread-pool.c:195)
5   libsystem_pthread.dylib                0x199a89f94 _pthread_start + 136
6   libsystem_pthread.dylib                0x199a84d34 thread_start + 8

Thread 4:: Finalizer
0   libsystem_kernel.dylib                 0x199a48d70 semaphore_wait_trap + 8
1   MyApp.Mobile                           0x10089e970 mono_os_sem_wait + 12 (mono-os-semaphore.h:85) [inlined]
2   MyApp.Mobile                           0x10089e970 mono_coop_sem_wait + 32 (mono-coop-semaphore.h:41) [inlined]
3   MyApp.Mobile                           0x10089e970 finalizer_thread + 328 (gc.c:891)
4   MyApp.Mobile                           0x10087b3b4 start_wrapper_internal + 284 (threads.c:1202) [inlined]
5   MyApp.Mobile                           0x10087b3b4 start_wrapper + 352 (threads.c:1271)
6   libsystem_pthread.dylib                0x199a89f94 _pthread_start + 136
7   libsystem_pthread.dylib                0x199a84d34 thread_start + 8

Thread 5:
0   libsystem_pthread.dylib                0x199a84d20 start_wqthread + 0

Thread 6:
0   libsystem_pthread.dylib                0x199a84d20 start_wqthread + 0

Thread 7:: com.apple.uikit.eventfetch-thread
0   libsystem_kernel.dylib                 0x199a48df4 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x199a5b5e4 mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x199a519c4 mach_msg_overwrite + 476
3   libsystem_kernel.dylib                 0x199a49178 mach_msg + 24
4   CoreFoundation                         0x199b69680 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x199b67f44 __CFRunLoopRun + 1208
6   CoreFoundation                         0x199b67434 CFRunLoopRunSpecific + 608
7   Foundation                             0x19ac9b868 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8   Foundation                             0x19ad10d80 -[NSRunLoop(NSRunLoop) runUntilDate:] + 100
9   UIKitCore                              0x1c901eb88 -[UIEventFetcher threadMain] + 104
10  Foundation                             0x19ac94d60 __NSThread__start__ + 716
11  libsystem_pthread.dylib                0x199a89f94 _pthread_start + 136
12  libsystem_pthread.dylib                0x199a84d34 thread_start + 8

Thread 8:
0   libsystem_pthread.dylib                0x199a84d20 start_wqthread + 0

Thread 9:: com.apple.NSEventThread
0   libsystem_kernel.dylib                 0x199a48df4 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x199a5b5e4 mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x199a519c4 mach_msg_overwrite + 476
3   libsystem_kernel.dylib                 0x199a49178 mach_msg + 24
4   CoreFoundation                         0x199b69680 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x199b67f44 __CFRunLoopRun + 1208
6   CoreFoundation                         0x199b67434 CFRunLoopRunSpecific + 608
7   AppKit                                 0x19d4f1280 _NSEventThread + 144
8   libsystem_pthread.dylib                0x199a89f94 _pthread_start + 136
9   libsystem_pthread.dylib                0x199a84d34 thread_start + 8

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x00000001380f2600   x1: 0x000000013815f36a   x2: 0xffffffffffffffe9   x3: 0x00000001380f4149
    x4: 0x000000000006b201   x5: 0x0000000000000020   x6: 0x00000001380f2600   x7: 0x0000000000001b89
    x8: 0x0000000201e39000   x9: 0x89e4b3112f3500c6  x10: 0x89e4b3112f3500c6  x11: 0x000000000000007f
   x12: 0x0000000000000017  x13: 0x00000001369f7760  x14: 0x01000002018f0589  x15: 0x00000002018f0588
   x16: 0x0000000199aba1a0  x17: 0x000000020bfd6aa8  x18: 0x0000000000000000  x19: 0x0000600000842cd0
   x20: 0x000060000130fbc0  x21: 0x0000000000000001  x22: 0x0000000000000000  x23: 0x0000600000842d30
   x24: 0x0000000000002000  x25: 0x000000000000002f  x26: 0x000000016fd5d1c8  x27: 0x0000000206a87000
   x28: 0x0000000000000000   fp: 0x000000016fd5d000   lr: 0x327880019d6a3750
    sp: 0x000000016fd5cfd0   pc: 0x000000019d6a3758 cpsr: 0x60001000
   far: 0x0000000000000000  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x101804000 -        0x10180ffff libobjc-trampolines.dylib (*) <7d6ca1cb-c5e6-38b6-9618-2c580486fc6b> /usr/lib/libobjc-trampolines.dylib
       0x101d0c000 -        0x10226ffff com.microsoft.libSkiaSharp (1.0) <e8dbf01e-3957-3ad5-89a5-df0f96660a83> /Volumes/VOLUME/*/MyApp.Mobile.app/Frameworks/libSkiaSharp.framework/libSkiaSharp
       0x1000a0000 -        0x100acffff co.uk.MyApp (1.0.4871) <4ade2607-3e58-3ce6-b912-9c8d15644c22> /Volumes/VOLUME/*/MyApp.Mobile.app/MyApp.Mobile
       0x19d38d000 -        0x19e6cbfff com.apple.AppKit (6.9) <7acbeef9-a453-3e4d-98ac-f9441d86e183> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
       0x199aeb000 -        0x199fc3fff com.apple.CoreFoundation (6.9) <55720ee0-d8c3-33a1-9854-8e61a6f44895> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x1996a8000 -        0x1996f8e0b libobjc.A.dylib (*) <5c6386bd-f308-3370-bce9-63d1a89dab87> /usr/lib/libobjc.A.dylib
       0x199a2c000 -        0x199a47ffb libc++abi.dylib (*) <68e3eb36-b4ba-30e0-a240-31e942936d06> /usr/lib/libc++abi.dylib
       0x1998d5000 -        0x19991cfff libdispatch.dylib (*) <1a1ce00a-89cd-36ba-9678-5038aedd0d8d> /usr/lib/system/libdispatch.dylib
       0x1af677000 -        0x1af732fff com.apple.FrontBoardServices (867.314) <992b0ceb-86e8-3d0a-9913-2a88673c4cc5> /System/Library/PrivateFrameworks/FrontBoardServices.framework/Versions/A/FrontBoardServices
       0x1a42de000 -        0x1a45a1fff com.apple.HIToolbox (2.1.1) <4166f6cb-b599-306c-8568-823bd29a74c3> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
       0x1b2e41000 -        0x1b2f54fff com.apple.UIKitMacHelper (1.0) <dcee2523-2e56-3bfb-994e-1899f0c91cb0> /System/Library/PrivateFrameworks/UIKitMacHelper.framework/Versions/A/UIKitMacHelper
       0x1c901a000 -        0x1ca9aafff com.apple.UIKitCore (1.0) <ed661c3f-1da0-3e80-aced-894daf8c3aa2> /System/iOSSupport/System/Library/PrivateFrameworks/UIKitCore.framework/Versions/A/UIKitCore
       0x1996f9000 -        0x199782507 dyld (*) <f635824e-318b-3f0c-842c-c369737f2b68> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x199ab6000 -        0x199abdfe7 libsystem_platform.dylib (*) <b4bf9f89-31d7-3742-8ce7-ab3554f9f525> /usr/lib/system/libsystem_platform.dylib
       0x199a83000 -        0x199a8ffff libsystem_pthread.dylib (*) <e03e8478-6f5c-3d21-a79a-58408f514000> /usr/lib/system/libsystem_pthread.dylib
       0x199a48000 -        0x199a82ffb libsystem_kernel.dylib (*) <71ff45b8-f14e-3666-9e96-6cf58315b91d> /usr/lib/system/libsystem_kernel.dylib
       0x19ac40000 -        0x19b89dfff com.apple.Foundation (6.9) <c6949f67-60f6-3735-b583-bf1e069a8a0b> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation

EOF
rolfbjarne commented 3 months ago
1   libobjc.A.dylib                        0x1996c2158 objc_exception_throw + 60
2   MyApp.Mobile                           0x1005ceca0 xamarin_unhandled_exception_handler + 0 (runtime.m:1128)
3   MyApp.Mobile                           0x10092d184 native_to_managed_trampoline_3(objc_object*, objc_selector*, _MonoMethod**, objc_object*, objc_object*, unsigned int) + 864 (registrar.mm:190)
4   MyApp.Mobile                           0x10092d204 -[Microsoft_Maui_MauiUIApplicationDelegate application:didFinishLaunchingWithOptions:] + 64 (registrar.mm:10131)

The managed DidFinishLaunching method threw an exception, and since it's unhandled, the app crashes.

Looking at the device log might reveal more information about the managed exception.

sumowesley commented 3 months ago
1   libobjc.A.dylib                          0x1996c2158 objc_exception_throw + 60
2   MyApp.Mobile                             0x1005ceca0 xamarin_unhandled_exception_handler + 0 (runtime.m:1128)
3   MyApp.Mobile                             0x10092d184 native_to_managed_trampoline_3(objc_object*, objc_selector*, _MonoMethod**, objc_object*, objc_object*, unsigned int) + 864 (registrar.mm:190)
4   MyApp.Mobile                             0x10092d204 -[Microsoft_Maui_MauiUIApplicationDelegate application:didFinishLaunchingWithOptions:] + 64 (registrar.mm:10131)

The managed DidFinishLaunching method threw an exception, and since it's unhandled, the app crashes.

Looking at the device log might reveal more information about the managed exception.

Indeed, that's where I thought the AutoMapper startup was the culprit. I took it away and put it back piece by piece. And then it worked. I'm leaning more towards removing bin and obj, which must have happened during and not before the AutoMapper work; otherwise, I'm left with a big mystery. I appreciate your steer.

r-work commented 3 months ago

@rolfbjarne device log seems to have the same crash log. one thing I've noticed, if I debug using a simulator, it works fine, but it crashes on a real device. And it doesn't throw at a particular place, for example you can set a breakpoint at MauiProgram.CreateMauiApp it stops there for a second or two, then crashes without throwing anything anywhere, as if it crashes on a separate thread.

rolfbjarne commented 3 months ago

@r-work

device log seems to have the same crash log.

For unhandled exceptions, more information about the exception should be printed to the device log.

or example you can set a breakpoint at MauiProgram.CreateMauiApp it stops there for a second or two, then crashes without throwing anything anywhere

This is probably because the iOS device as a launch watchdog, which will terminate your app if it doesn't launch within a certain time (20s).

r-work commented 3 months ago

@rolfbjarne thanks for your help, I think I got to the bottom of it. It was throwing an exception in my code, but because it was on startup, setting break points didn't help as iOS still killed the app for taking too long.

samhouts commented 3 months ago

This looks resolved, so I will close it. Please comment if it needs more attention. Thanks!