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
21.99k stars 1.72k forks source link

[MacCatalyst] Failure to run in release mode (arm64) #24404

Closed sumowesley closed 2 weeks ago

sumowesley commented 3 weeks ago

Description

When I run my .NET MAUI app on the MacBook Air M1, it crashes almost immediately. This crash happens when the app runs in Release mode from the command line or when TestFlight installs it on the device. Release mode on my x64 Mac works fine from the command line and via TestFlight.

The iOS version of the app deploys OK via TestFlight.

Steps to Reproduce

TestFlight method

  1. Build combined and signed pkg file on Macbook Air M1
  2. Submit pkg to TestFlight using Transporter
  3. Install the application from TestFlight and run

Local command line method

dotnet clean dotnet build -f net8.0-maccatalyst -c Release dotnet run --no-launch-profile -f net8.0-maccatalyst -c Release

Link to public reproduction project repository

No response

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

Sonoma 14.6.1,

Did you find any workaround?

No response

Relevant log output

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               MossUI [21368]
Path:                  /Users/Shared/*/MossUI.app/Contents/MacOS/MossUI
Identifier:            uk.co.fivesixsolutions.MossUI
Version:               1.0 (11)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2024-08-23 14:46:10.7747 +0100
OS Version:            macOS 14.6.1 (23G93)
Report Version:        12
Anonymous UUID:        1DD3DFF6-702E-AFD5-4651-15C4612738D0

Sleep/Wake UUID:       6E43F0DD-14F6-4108-B6AB-CB4538056FC7

Time Awake Since Boot: 21000 seconds
Time Since Wake:       20532 seconds

System Integrity Protection: enabled

Crashed Thread:        0  tid_103  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   MossUI [21368]

Application Specific Information:
abort() called

Thread 0 Crashed:: tid_103 Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x18b3995f0 __pthread_kill + 8
1   libsystem_pthread.dylib                0x18b3d1c20 pthread_kill + 288
2   libsystem_c.dylib                      0x18b2dea30 abort + 180
3   MossUI                                 0x10b6872d4 sigabrt_signal_handler.cold.1 + 48 (mini-posix.c:226)
4   MossUI                                 0x10b647a7c sigabrt_signal_handler + 196 (mini-posix.c:224)
5   libsystem_platform.dylib               0x18b402584 _sigtramp + 56
6   libsystem_pthread.dylib                0x18b3d1c20 pthread_kill + 288
7   libsystem_c.dylib                      0x18b2dea30 abort + 180
8   MossUI                                 0x10b4821fc mono_log_write_os_log + 408 (mono-log-darwin.c:58)
9   MossUI                                 0x10b47740c monoeg_g_logstr + 44 (goutput.c:151) [inlined]
10  MossUI                                 0x10b47740c monoeg_g_logv_nofree + 136 (goutput.c:166) [inlined]
11  MossUI                                 0x10b47740c monoeg_g_logv + 172 (goutput.c:173)
12  MossUI                                 0x10b477554 monoeg_g_log + 28 (goutput.c:182)
13  MossUI                                 0x10b5e91a8 load_aot_module + 4268 (aot-runtime.c:2364)
14  MossUI                                 0x10b4d7298 mono_assembly_invoke_load_hook_internal + 92 (assembly.c:1081) [inlined]
15  MossUI                                 0x10b4d7298 mono_assembly_request_load_from + 1104 (assembly.c:2020)
16  MossUI                                 0x10b4d6db8 mono_assembly_request_open + 472 (assembly.c:1625)
17  MossUI                                 0x10b4d8a50 mono_assembly_open + 88 (assembly.c:1828)
18  MossUI                                 0x10b2f7558 xamarin_assembly_preload_hook + 452 (monotouch-main.m:157)
19  MossUI                                 0x10b4d8c88 invoke_assembly_preload_hook + 76 (assembly.c:1283)
20  MossUI                                 0x10b4d650c netcore_load_reference + 480 (assembly.c:827) [inlined]
21  MossUI                                 0x10b4d650c mono_assembly_request_byname + 1012 (assembly.c:2786)
22  MossUI                                 0x10b5f2fa4 load_image + 280 (aot-runtime.c:325)
23  MossUI                                 0x10b5e9140 load_aot_module + 4164 (aot-runtime.c:2356)
24  MossUI                                 0x10b4d7298 mono_assembly_invoke_load_hook_internal + 92 (assembly.c:1081) [inlined]
25  MossUI                                 0x10b4d7298 mono_assembly_request_load_from + 1104 (assembly.c:2020)
26  MossUI                                 0x10b4d6db8 mono_assembly_request_open + 472 (assembly.c:1625)
27  MossUI                                 0x10b4d8a50 mono_assembly_open + 88 (assembly.c:1828)
28  MossUI                                 0x10b2f7558 xamarin_assembly_preload_hook + 452 (monotouch-main.m:157)
29  MossUI                                 0x10b4d8c88 invoke_assembly_preload_hook + 76 (assembly.c:1283)
30  MossUI                                 0x10b4d650c netcore_load_reference + 480 (assembly.c:827) [inlined]
31  MossUI                                 0x10b4d650c mono_assembly_request_byname + 1012 (assembly.c:2786)
32  MossUI                                 0x10b5f2fa4 load_image + 280 (aot-runtime.c:325)
33  MossUI                                 0x10b5e9140 load_aot_module + 4164 (aot-runtime.c:2356)
34  MossUI                                 0x10b5edb8c load_container_amodule + 180 (aot-runtime.c:2488) [inlined]
35  MossUI                                 0x10b5edb8c mono_aot_get_method + 304 (aot-runtime.c:4896)
36  MossUI                                 0x10b58e38c mono_jit_compile_method_with_opt + 444 (mini-runtime.c:2747) [inlined]
37  MossUI                                 0x10b58e38c jit_compile_method_with_opt_cb + 456 (mini-runtime.c:2868) [inlined]
38  MossUI                                 0x10b58e38c jit_compile_method_with_opt + 556 (mini-runtime.c:2884)
39  MossUI                                 0x10b592830 mono_jit_compile_method_jit_only + 40 (mini-runtime.c:2922) [inlined]
40  MossUI                                 0x10b592830 mono_jit_runtime_invoke + 540 (mini-runtime.c:3514)
41  MossUI                                 0x10b536b64 do_runtime_invoke + 60 (object.c:2576) [inlined]
42  MossUI                                 0x10b536b64 mono_runtime_invoke_checked + 148 (object.c:2792)
43  MossUI                                 0x10b4f40ac create_exception_two_strings + 592 (exception.c:176)
44  MossUI                                 0x10b4f3e30 mono_exception_from_name_two_strings_checked + 148 (exception.c:236)
45  MossUI                                 0x10b4d2ea8 create_domain_objects + 88 (appdomain.c:192) [inlined]
46  MossUI                                 0x10b4d2ea8 mono_runtime_init_checked + 712 (appdomain.c:288)
47  MossUI                                 0x10b592108 mini_init + 6692 (mini-runtime.c:4875)
48  MossUI                                 0x10b5e55a0 mono_jit_init_version + 20 (driver.c:2823)
49  MossUI                                 0x10b2f6a60 xamarin_bridge_initialize + 164 (monovm-bridge.m:88)
50  MossUI                                 0x10b2f77e0 xamarin_main + 256 (monotouch-main.m:436)
51  MossUI                                 0x10b686ee0 main + 64 (main.arm64.mm:446)
52  dyld                                   0x18b047154 start + 2476

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

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

Thread 3:
0   libsystem_pthread.dylib                0x18b3ccd20 start_wqthread + 0

Thread 4:: SGen worker
0   libsystem_kernel.dylib                 0x18b3945ec __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x18b3d255c _pthread_cond_wait + 1228
2   MossUI                                 0x10b4d01f0 mono_os_cond_wait + 8 (mono-os-mutex.h:219) [inlined]
3   MossUI                                 0x10b4d01f0 get_work + 228 (sgen-thread-pool.c:164) [inlined]
4   MossUI                                 0x10b4d01f0 thread_func + 440 (sgen-thread-pool.c:195)
5   libsystem_pthread.dylib                0x18b3d1f94 _pthread_start + 136
6   libsystem_pthread.dylib                0x18b3ccd34 thread_start + 8

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0xffffffffa073f959   x5: 0x0000000000000008   x6: 0x000000016b107ca0   x7: 0x000000016b107390
    x8: 0xd5cc8b81993a0a70   x9: 0xd5cc8b806a180530  x10: 0x0000000000000200  x11: 0x000000016b107400
   x12: 0x0000000000000000  x13: 0x000000010b088fb8  x14: 0x00000001800fcb90  x15: 0x0000000000000001
   x16: 0x0000000000000148  x17: 0x00000001fd9224e8  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x00000001f3220f40  x21: 0x0000000000000103  x22: 0x00000001f3221020  x23: 0x000000000000030c
   x24: 0x000000010bbf04e4  x25: 0x0000000000000028  x26: 0x00000000000001b8  x27: 0x000000010b89dce0
   x28: 0x00006000037df6c0   fp: 0x000000016b107cb0   lr: 0x000000018b3d1c20
    sp: 0x000000016b107c90   pc: 0x000000018b3995f0 cpsr: 0x40001000
   far: 0x0000000000000000  esr: 0x56000080  Address size fault

Binary Images:
       0x1138d4000 -        0x1138dffff libobjc-trampolines.dylib (*) <7d6ca1cb-c5e6-38b6-9618-2c580486fc6b> /usr/lib/libobjc-trampolines.dylib
       0x11471c000 -        0x114c3ffff io.realm.wrappers (10.0.0) <6d36d580-6635-352c-bd3a-f873ca8c24ab> /Users/Shared/*/MossUI.app/Contents/Frameworks/realm-wrappers.framework/Versions/A/realm-wrappers
       0x114e58000 -        0x1153b3fff com.microsoft.libSkiaSharp (1.0) <52861d96-82ed-3ecf-b296-68d6f76d502d> /Users/Shared/*/MossUI.app/Contents/Frameworks/libSkiaSharp.framework/Versions/A/libSkiaSharp
       0x104cf4000 -        0x10b857fff uk.co.fivesixsolutions.MossUI (1.0) <d2074064-8be4-345e-8a97-b537a30eae39> /Users/Shared/*/MossUI.app/Contents/MacOS/MossUI
       0x18b390000 -        0x18b3caffb libsystem_kernel.dylib (*) <71ff45b8-f14e-3666-9e96-6cf58315b91d> /usr/lib/system/libsystem_kernel.dylib
       0x18b3cb000 -        0x18b3d7fff libsystem_pthread.dylib (*) <e03e8478-6f5c-3d21-a79a-58408f514000> /usr/lib/system/libsystem_pthread.dylib
       0x18b268000 -        0x18b2e6ff7 libsystem_c.dylib (*) <d30f1830-93d0-3d0b-8cba-9544e84bfd5b> /usr/lib/system/libsystem_c.dylib
       0x18b3fe000 -        0x18b405fe7 libsystem_platform.dylib (*) <b4bf9f89-31d7-3742-8ce7-ab3554f9f525> /usr/lib/system/libsystem_platform.dylib
       0x18b041000 -        0x18b0ca507 dyld (*) <f635824e-318b-3f0c-842c-c369737f2b68> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 1
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=1.6G resident=0K(0%) swapped_out_or_unallocated=1.6G(100%)
Writable regions: Total=873.9M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=873.9M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
ColorSync                           16K        1 
CoreServices                        80K        1 
Foundation                          16K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           839.2M       26 
MALLOC guard page                   96K        6 
STACK GUARD                       56.1M        5 
Stack                             10.1M        5 
VM_ALLOCATE                       5152K        8 
VM_ALLOCATE (reserved)            16.0M        1         reserved VM address space (unallocated)
__AUTH                            3846K      551 
__AUTH_CONST                      38.9M      786 
__CTF                               824        1 
__DATA                            20.7M      774 
__DATA_CONST                      43.1M      798 
__DATA_DIRTY                      2794K      305 
__FONT_DATA                          4K        1 
__INFO_FILTER                         8        1 
__LINKEDIT                       647.0M        5 
__OBJC_RO                         71.9M        2 
__OBJC_RW                         2200K        1 
__TEXT                           965.3M      817 
dyld private memory                272K        2 
mapped file                       60.8M       78 
shared memory                      752K        8 
===========                     =======  ======= 
TOTAL                              2.7G     4186 
TOTAL, minus reserved VM space     2.7G     4186 

-----------
Full Report
-----------

{"app_name":"MossUI","timestamp":"2024-08-23 14:46:11.00 +0100","app_version":"1.0","slice_uuid":"d2074064-8be4-345e-8a97-b537a30eae39","build_version":"11","platform":6,"bundleID":"uk.co.fivesixsolutions.MossUI","share_with_app_devs":1,"is_first_party":0,"bug_type":"309","os_version":"macOS 14.6.1 (23G93)","roots_installed":0,"name":"MossUI","incident_id":"B146DC7A-FAB2-4517-BF55-4BF4B8FF070C"}
{
  "uptime" : 21000,
  "procRole" : "Background",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookAir10,1",
  "coalitionID" : 5696,
  "osVersion" : {
    "train" : "macOS 14.6.1",
    "build" : "23G93",
    "releaseType" : "User"
  },
  "captureTime" : "2024-08-23 14:46:10.7747 +0100",
  "codeSigningMonitor" : 1,
  "incident" : "B146DC7A-FAB2-4517-BF55-4BF4B8FF070C",
  "pid" : 21368,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2024-08-23 14:46:05.2718 +0100",
  "procStartAbsTime" : 516787723738,
  "procExitAbsTime" : 516919786274,
  "procName" : "MossUI",
  "procPath" : "\/Users\/Shared\/*\/MossUI.app\/Contents\/MacOS\/MossUI",
  "bundleInfo" : {"CFBundleShortVersionString":"1.0","CFBundleVersion":"11","CFBundleIdentifier":"uk.co.fivesixsolutions.MossUI"},
  "storeInfo" : {"deviceIdentifierForVendor":"2CF8CD50-6DBD-53DC-9654-306673C68F5C","thirdParty":true},
  "parentProc" : "launchd",
  "parentPid" : 1,
  "coalitionName" : "uk.co.fivesixsolutions.MossUI",
  "crashReporterKey" : "1DD3DFF6-702E-AFD5-4651-15C4612738D0",
  "codeSigningID" : "uk.co.fivesixsolutions.MossUI",
  "codeSigningTeamID" : "",
  "codeSigningFlags" : 570425857,
  "codeSigningValidationCategory" : 10,
  "codeSigningTrustLevel" : 4294967295,
  "instructionByteStream" : {"beforePC":"fyMD1f17v6n9AwCRd+D\/l78DAJH9e8Go\/w9f1sADX9YQKYDSARAA1A==","atPC":"AwEAVH8jA9X9e7+p\/QMAkWzg\/5e\/AwCR\/XvBqP8PX9bAA1\/WcAqA0g=="},
  "wakeTime" : 20532,
  "sleepWakeUUID" : "6E43F0DD-14F6-4108-B6AB-CB4538056FC7",
  "sip" : "enabled",
  "exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
  "termination" : {"flags":0,"code":6,"namespace":"SIGNAL","indicator":"Abort trap: 6","byProc":"MossUI","byPid":21368},
  "asi" : {"libsystem_c.dylib":["abort() called"]},
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":1},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"threadState":{"x":[{"value":0},{"value":0},{"value":0},{"value":0},{"value":18446744072106539353},{"value":8},{"value":6091209888},{"value":6091207568},{"value":15405841814065384048},{"value":15405841808979658032},{"value":512},{"value":6091207680},{"value":0},{"value":4480077752,"symbolLocation":0,"symbol":"jit_code_end"},{"value":6443486096},{"value":1},{"value":328},{"value":8549180648},{"value":0},{"value":6},{"value":8374062912,"symbolLocation":0,"symbol":"_main_thread"},{"value":259},{"value":8374063136,"symbolLocation":224,"symbol":"_main_thread"},{"value":780},{"value":4492035300,"symbolLocation":0,"symbol":"mono_aot_only"},{"value":40},{"value":440},{"value":4488551648,"symbolLocation":0,"symbol":"mono_aot_mode"},{"value":105553174853312}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6631005216},"cpsr":{"value":1073745920},"fp":{"value":6091209904},"sp":{"value":6091209872},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6630774256,"matchesCrashFrame":1},"far":{"value":0}},"id":283800,"triggered":true,"name":"tid_103","queue":"com.apple.main-thread","frames":[{"imageOffset":38384,"symbol":"__pthread_kill","symbolLocation":8,"imageIndex":4},{"imageOffset":27680,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":5},{"imageOffset":485936,"symbol":"abort","symbolLocation":180,"imageIndex":6},{"imageOffset":110703316,"sourceLine":226,"sourceFile":"mini-posix.c","symbol":"sigabrt_signal_handler.cold.1","imageIndex":3,"symbolLocation":48},{"imageOffset":110443132,"sourceLine":224,"sourceFile":"mini-posix.c","symbol":"sigabrt_signal_handler","imageIndex":3,"symbolLocation":196},{"imageOffset":17796,"symbol":"_sigtramp","symbolLocation":56,"imageIndex":7},{"imageOffset":27680,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":5},{"imageOffset":485936,"symbol":"abort","symbolLocation":180,"imageIndex":6},{"imageOffset":108585468,"sourceLine":58,"sourceFile":"mono-log-darwin.c","symbol":"mono_log_write_os_log","imageIndex":3,"symbolLocation":408},{"symbol":"monoeg_g_logstr","inline":true,"imageIndex":3,"imageOffset":108540940,"symbolLocation":44,"sourceLine":151,"sourceFile":"goutput.c"},{"symbol":"monoeg_g_logv_nofree","inline":true,"imageIndex":3,"imageOffset":108540940,"symbolLocation":136,"sourceLine":166,"sourceFile":"goutput.c"},{"imageOffset":108540940,"sourceLine":173,"sourceFile":"goutput.c","symbol":"monoeg_g_logv","imageIndex":3,"symbolLocation":172},{"imageOffset":108541268,"sourceLine":182,"sourceFile":"goutput.c","symbol":"monoeg_g_log","imageIndex":3,"symbolLocation":28},{"imageOffset":110055848,"sourceLine":2364,"sourceFile":"aot-runtime.c","symbol":"load_aot_module","imageIndex":3,"symbolLocation":4268},{"symbol":"mono_assembly_invoke_load_hook_internal","inline":true,"imageIndex":3,"imageOffset":108933784,"symbolLocation":92,"sourceLine":1081,"sourceFile":"assembly.c"},{"imageOffset":108933784,"sourceLine":2020,"sourceFile":"assembly.c","symbol":"mono_assembly_request_load_from","imageIndex":3,"symbolLocation":1104},{"imageOffset":108932536,"sourceLine":1625,"sourceFile":"assembly.c","symbol":"mono_assembly_request_open","imageIndex":3,"symbolLocation":472},{"imageOffset":108939856,"sourceLine":1828,"sourceFile":"assembly.c","symbol":"mono_assembly_open","imageIndex":3,"symbolLocation":88},{"imageOffset":106968408,"sourceLine":157,"sourceFile":"monotouch-main.m","symbol":"xamarin_assembly_preload_hook","imageIndex":3,"symbolLocation":452},{"imageOffset":108940424,"sourceLine":1283,"sourceFile":"assembly.c","symbol":"invoke_assembly_preload_hook","imageIndex":3,"symbolLocation":76},{"symbol":"netcore_load_reference","inline":true,"imageIndex":3,"imageOffset":108930316,"symbolLocation":480,"sourceLine":827,"sourceFile":"assembly.c"},{"imageOffset":108930316,"sourceLine":2786,"sourceFile":"assembly.c","symbol":"mono_assembly_request_byname","imageIndex":3,"symbolLocation":1012},{"imageOffset":110096292,"sourceLine":325,"sourceFile":"aot-runtime.c","symbol":"load_image","imageIndex":3,"symbolLocation":280},{"imageOffset":110055744,"sourceLine":2356,"sourceFile":"aot-runtime.c","symbol":"load_aot_module","imageIndex":3,"symbolLocation":4164},{"symbol":"mono_assembly_invoke_load_hook_internal","inline":true,"imageIndex":3,"imageOffset":108933784,"symbolLocation":92,"sourceLine":1081,"sourceFile":"assembly.c"},{"imageOffset":108933784,"sourceLine":2020,"sourceFile":"assembly.c","symbol":"mono_assembly_request_load_from","imageIndex":3,"symbolLocation":1104},{"imageOffset":108932536,"sourceLine":1625,"sourceFile":"assembly.c","symbol":"mono_assembly_request_open","imageIndex":3,"symbolLocation":472},{"imageOffset":108939856,"sourceLine":1828,"sourceFile":"assembly.c","symbol":"mono_assembly_open","imageIndex":3,"symbolLocation":88},{"imageOffset":106968408,"sourceLine":157,"sourceFile":"monotouch-main.m","symbol":"xamarin_assembly_preload_hook","imageIndex":3,"symbolLocation":452},{"imageOffset":108940424,"sourceLine":1283,"sourceFile":"assembly.c","symbol":"invoke_assembly_preload_hook","imageIndex":3,"symbolLocation":76},{"symbol":"netcore_load_reference","inline":true,"imageIndex":3,"imageOffset":108930316,"symbolLocation":480,"sourceLine":827,"sourceFile":"assembly.c"},{"imageOffset":108930316,"sourceLine":2786,"sourceFile":"assembly.c","symbol":"mono_assembly_request_byname","imageIndex":3,"symbolLocation":1012},{"imageOffset":110096292,"sourceLine":325,"sourceFile":"aot-runtime.c","symbol":"load_image","imageIndex":3,"symbolLocation":280},{"imageOffset":110055744,"sourceLine":2356,"sourceFile":"aot-runtime.c","symbol":"load_aot_module","imageIndex":3,"symbolLocation":4164},{"symbol":"load_container_amodule","inline":true,"imageIndex":3,"imageOffset":110074764,"symbolLocation":180,"sourceLine":2488,"sourceFile":"aot-runtime.c"},{"imageOffset":110074764,"sourceLine":4896,"sourceFile":"aot-runtime.c","symbol":"mono_aot_get_method","imageIndex":3,"symbolLocation":304},{"symbol":"mono_jit_compile_method_with_opt","inline":true,"imageIndex":3,"imageOffset":109683596,"symbolLocation":444,"sourceLine":2747,"sourceFile":"mini-runtime.c"},{"symbol":"jit_compile_method_with_opt_cb","inline":true,"imageIndex":3,"imageOffset":109683596,"symbolLocation":456,"sourceLine":2868,"sourceFile":"mini-runtime.c"},{"imageOffset":109683596,"sourceLine":2884,"sourceFile":"mini-runtime.c","symbol":"jit_compile_method_with_opt","imageIndex":3,"symbolLocation":556},{"symbol":"mono_jit_compile_method_jit_only","inline":true,"imageIndex":3,"imageOffset":109701168,"symbolLocation":40,"sourceLine":2922,"sourceFile":"mini-runtime.c"},{"imageOffset":109701168,"sourceLine":3514,"sourceFile":"mini-runtime.c","symbol":"mono_jit_runtime_invoke","imageIndex":3,"symbolLocation":540},{"symbol":"do_runtime_invoke","inline":true,"imageIndex":3,"imageOffset":109325156,"symbolLocation":60,"sourceLine":2576,"sourceFile":"object.c"},{"imageOffset":109325156,"sourceLine":2792,"sourceFile":"object.c","symbol":"mono_runtime_invoke_checked","imageIndex":3,"symbolLocation":148},{"imageOffset":109052076,"sourceLine":176,"sourceFile":"exception.c","symbol":"create_exception_two_strings","imageIndex":3,"symbolLocation":592},{"imageOffset":109051440,"sourceLine":236,"sourceFile":"exception.c","symbol":"mono_exception_from_name_two_strings_checked","imageIndex":3,"symbolLocation":148},{"symbol":"create_domain_objects","inline":true,"imageIndex":3,"imageOffset":108916392,"symbolLocation":88,"sourceLine":192,"sourceFile":"appdomain.c"},{"imageOffset":108916392,"sourceLine":288,"sourceFile":"appdomain.c","symbol":"mono_runtime_init_checked","imageIndex":3,"symbolLocation":712},{"imageOffset":109699336,"sourceLine":4875,"sourceFile":"mini-runtime.c","symbol":"mini_init","imageIndex":3,"symbolLocation":6692},{"imageOffset":110040480,"sourceLine":2823,"sourceFile":"driver.c","symbol":"mono_jit_init_version","imageIndex":3,"symbolLocation":20},{"imageOffset":106965600,"sourceLine":88,"sourceFile":"monovm-bridge.m","symbol":"xamarin_bridge_initialize","imageIndex":3,"symbolLocation":164},{"imageOffset":106969056,"sourceLine":436,"sourceFile":"monotouch-main.m","symbol":"xamarin_main","imageIndex":3,"symbolLocation":256},{"imageOffset":110702304,"sourceLine":446,"sourceFile":"main.arm64.mm","symbol":"main","imageIndex":3,"symbolLocation":64},{"imageOffset":24916,"symbol":"start","symbolLocation":2476,"imageIndex":8}]},{"id":283972,"frames":[{"imageOffset":7456,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"x":[{"value":6091780096},{"value":5891},{"value":6091243520},{"value":0},{"value":409604},{"value":18446744073709551615},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":0},"cpsr":{"value":4096},"fp":{"value":0},"sp":{"value":6091780096},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6630984992},"far":{"value":0}}},{"id":283974,"frames":[{"imageOffset":7456,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"x":[{"value":6092353536},{"value":8195},{"value":6091816960},{"value":0},{"value":409604},{"value":18446744073709551615},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":0},"cpsr":{"value":4096},"fp":{"value":0},"sp":{"value":6092353536},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6630984992},"far":{"value":0}}},{"id":283975,"frames":[{"imageOffset":7456,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}],"threadState":{"x":[{"value":6092926976},{"value":0},{"value":6092390400},{"value":0},{"value":278532},{"value":18446744073709551615},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":0},"cpsr":{"value":4096},"fp":{"value":0},"sp":{"value":6092926976},"esr":{"value":0,"description":" Address size fault"},"pc":{"value":6630984992},"far":{"value":0}}},{"id":283985,"name":"SGen worker","threadState":{"x":[{"value":260},{"value":0},{"value":0},{"value":0},{"value":0},{"value":161},{"value":0},{"value":0},{"value":6093500072},{"value":0},{"value":4492005360,"symbolLocation":160,"symbol":"_MergedGlobals"},{"value":2},{"value":0},{"value":0},{"value":0},{"value":0},{"value":305},{"value":8549180576},{"value":0},{"value":4492005336,"symbolLocation":136,"symbol":"_MergedGlobals"},{"value":4492005240,"symbolLocation":40,"symbol":"_MergedGlobals"},{"value":6093500640},{"value":0},{"value":0},{"value":0},{"value":1},{"value":256},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6631007580},"cpsr":{"value":1610616832},"fp":{"value":6093500192},"sp":{"value":6093500048},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6630753772},"far":{"value":0}},"frames":[{"imageOffset":17900,"symbol":"__psynch_cvwait","symbolLocation":8,"imageIndex":4},{"imageOffset":30044,"symbol":"_pthread_cond_wait","symbolLocation":1228,"imageIndex":5},{"symbol":"mono_os_cond_wait","inline":true,"imageIndex":3,"imageOffset":108904944,"symbolLocation":8,"sourceLine":219,"sourceFile":"mono-os-mutex.h"},{"symbol":"get_work","inline":true,"imageIndex":3,"imageOffset":108904944,"symbolLocation":228,"sourceLine":164,"sourceFile":"sgen-thread-pool.c"},{"imageOffset":108904944,"sourceLine":195,"sourceFile":"sgen-thread-pool.c","symbol":"thread_func","imageIndex":3,"symbolLocation":440},{"imageOffset":28564,"symbol":"_pthread_start","symbolLocation":136,"imageIndex":5},{"imageOffset":7476,"symbol":"thread_start","symbolLocation":8,"imageIndex":5}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 4622991360,
    "size" : 49152,
    "uuid" : "7d6ca1cb-c5e6-38b6-9618-2c580486fc6b",
    "path" : "\/usr\/lib\/libobjc-trampolines.dylib",
    "name" : "libobjc-trampolines.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4637966336,
    "CFBundleShortVersionString" : "10.0.0",
    "CFBundleIdentifier" : "io.realm.wrappers",
    "size" : 5390336,
    "uuid" : "6d36d580-6635-352c-bd3a-f873ca8c24ab",
    "path" : "\/Users\/Shared\/*\/MossUI.app\/Contents\/Frameworks\/realm-wrappers.framework\/Versions\/A\/realm-wrappers",
    "name" : "realm-wrappers",
    "CFBundleVersion" : "10.0.0"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4645552128,
    "CFBundleShortVersionString" : "1.0",
    "CFBundleIdentifier" : "com.microsoft.libSkiaSharp",
    "size" : 5619712,
    "uuid" : "52861d96-82ed-3ecf-b296-68d6f76d502d",
    "path" : "\/Users\/Shared\/*\/MossUI.app\/Contents\/Frameworks\/libSkiaSharp.framework\/Versions\/A\/libSkiaSharp",
    "name" : "libSkiaSharp",
    "CFBundleVersion" : "1"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4375658496,
    "CFBundleShortVersionString" : "1.0",
    "CFBundleIdentifier" : "uk.co.fivesixsolutions.MossUI",
    "size" : 112607232,
    "uuid" : "d2074064-8be4-345e-8a97-b537a30eae39",
    "path" : "\/Users\/Shared\/*\/MossUI.app\/Contents\/MacOS\/MossUI",
    "name" : "MossUI",
    "CFBundleVersion" : "11"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6630735872,
    "size" : 241660,
    "uuid" : "71ff45b8-f14e-3666-9e96-6cf58315b91d",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6630977536,
    "size" : 53248,
    "uuid" : "e03e8478-6f5c-3d21-a79a-58408f514000",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6629523456,
    "size" : 520184,
    "uuid" : "d30f1830-93d0-3d0b-8cba-9544e84bfd5b",
    "path" : "\/usr\/lib\/system\/libsystem_c.dylib",
    "name" : "libsystem_c.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6631186432,
    "size" : 32744,
    "uuid" : "b4bf9f89-31d7-3742-8ce7-ab3554f9f525",
    "path" : "\/usr\/lib\/system\/libsystem_platform.dylib",
    "name" : "libsystem_platform.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6627266560,
    "size" : 562440,
    "uuid" : "f635824e-318b-3f0c-842c-c369737f2b68",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  }
],
  "sharedCache" : {
  "base" : 6626508800,
  "size" : 4214358016,
  "uuid" : "bb3df3d3-38bd-304c-9233-e43de95f1903"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=1.6G resident=0K(0%) swapped_out_or_unallocated=1.6G(100%)\nWritable regions: Total=873.9M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=873.9M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nActivity Tracing                   256K        1 \nColorSync                           16K        1 \nCoreServices                        80K        1 \nFoundation                          16K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           839.2M       26 \nMALLOC guard page                   96K        6 \nSTACK GUARD                       56.1M        5 \nStack                             10.1M        5 \nVM_ALLOCATE                       5152K        8 \nVM_ALLOCATE (reserved)            16.0M        1         reserved VM address space (unallocated)\n__AUTH                            3846K      551 \n__AUTH_CONST                      38.9M      786 \n__CTF                               824        1 \n__DATA                            20.7M      774 \n__DATA_CONST                      43.1M      798 \n__DATA_DIRTY                      2794K      305 \n__FONT_DATA                          4K        1 \n__INFO_FILTER                         8        1 \n__LINKEDIT                       647.0M        5 \n__OBJC_RO                         71.9M        2 \n__OBJC_RW                         2200K        1 \n__TEXT                           965.3M      817 \ndyld private memory                272K        2 \nmapped file                       60.8M       78 \nshared memory                      752K        8 \n===========                     =======  ======= \nTOTAL                              2.7G     4186 \nTOTAL, minus reserved VM space     2.7G     4186 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "name" : "tid_103",
    "queue" : "com.apple.main-thread"
  }
},
  "logWritingSignature" : "1f318b4bdea18aaa199b261edf95c806c4eef30b",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "61675b89201f677a9a4cbd65",
      "factorPackIds" : {
        "HEALTH_FEATURE_AVAILABILITY" : "65a855f5f087695cfac03d1f"
      },
      "deploymentId" : 240000131
    },
    {
      "rolloutId" : "639124e81d92412bfb4880b3",
      "factorPackIds" : {

      },
      "deploymentId" : 240000012
    }
  ],
  "experiments" : [
    {
      "treatmentId" : "c47ab4cc-c9c3-4b5d-a87c-e2433ce02597",
      "experimentId" : "6639bc6ba73d460582162323",
      "deploymentId" : 400000006
    },
    {
      "treatmentId" : "45f4e2a5-551b-4bc2-a2dc-19c244dda8f8",
      "experimentId" : "6643969b3099cf28e049862f",
      "deploymentId" : 400000007
    }
  ]
}
}

Model: MacBookAir10,1, BootROM 10151.140.19, proc 8:4:4 processors, 16 GB, SMC 
Graphics: Apple M1, Apple M1, Built-In
Display: Color LCD, 2560 x 1600 Retina, Main, MirrorOff, Online
Display: LU28R55, 2560 x 1440 (QHD/WQHD - Wide Quad High Definition), MirrorOff, Online
Display: LU28R55, 2560 x 1440 (QHD/WQHD - Wide Quad High Definition), MirrorOff, Online
Memory Module: LPDDR4, Hynix
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x4378), wl0: Jan 13 2024 03:06:59 version 18.20.440.9.7.8.167 FWID 01-7be24857
AirPort: 
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: USB3.0 Hub
USB Device: USB3.0 2K Graphic Docking
USB Device: USB3.0 Hub
USB Device: USB3.1 Hub
USB Device: USB2.0 Hub
USB Device: USB2.0 Hub
USB Device: Generic Billboard Device
USB Device: USB2.1 Hub
USB Device: USB Receiver
USB Device: USB31Bus
Thunderbolt Bus: MacBook Air, Apple Inc.
Thunderbolt Bus: MacBook Air, Apple Inc.
github-actions[bot] commented 3 weeks 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!

Open similar issues:

Closed similar issues:

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

sumowesley commented 2 weeks ago

I've investigated this some more and found that I need to remove the bin and obj directories every time before running the app in release mode. The

dotnet clean

command is not enough to make it work.

We were interested because we would get to the login page, which would fail on arm64 but not x64. There is a reason for that, which I highlight in the following comment. I added a version number/architecture string on the login page. Having built a new pkg file for TestFlight, it deploys to the MacBook Air M1 as expected. However, when I run it, it shows X64 as the architecture, and to provide the point, it logs in. Deploying it through TestFlight on my i9 Mac works as expected.

Why does it misidentify the architecture and work appropriately as X64? Getting rid of some apps referenced with the same name from LaunchPad and a reinstall from TestFlight got round the problem. It now shows as arm64.

sumowesley commented 2 weeks ago

I extended the logging (Serilog run through Microsoft Extensions.Logging) to trap any issues I could find when accessing the database. I'm using AutoMapper here. When running locally on the MacBook Air M1, I have an error in the log that does not appear on X64 (which runs as expected).

2024-08-25 09:57:18.887 +01:00 [ERR] Could not read organisation: Attempting to JIT compile method '(wrapper dynamic-method) SharedCommon.Models.Authorisation.Organisation.Organisation object:Thunk1ret_Organisation_Object_Organisation_ResolutionContext (System.Func`2<object[], object>,object,SharedCommon.Models.Authorisation.Organisation.Organisation,AutoMapper.ResolutionContext)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) SharedCommon.Models.Authorisation.Organisation.Organisation object:Thunk1ret_Organisation_Object_Organisation_ResolutionContext (System.Func`2<object[], object>,object,SharedCommon.Models.Authorisation.Organisation.Organisation,AutoMapper.ResolutionContext)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed) at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure) at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method) at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type , Object ) at System.Dynamic.Utils.DelegateHelpers.CreateObjectArrayDelegateRefEmit(Type , Func2 ) at System.Dynamic.Utils.DelegateHelpers.CreateObjectArrayDelegate(Type , Func2 ) at System.Linq.Expressions.Interpreter.LightLambda.MakeDelegate(Type ) at System.Linq.Expressions.Interpreter.LightDelegateCreator.CreateDelegate(IStrongBox[] ) at System.Linq.Expressions.Interpreter.LightDelegateCreator.CreateDelegate() at System.Linq.Expressions.LambdaExpression.Compile() at AutoMapper.MapperConfiguration.<.ctor>gCompileExecutionPlan|20_2(MapRequest mapRequest) at AutoMapper.Internal.LockingConcurrentDictionary`2.<>c__DisplayClass2_1[[AutoMapper.Internal.MapRequest, AutoMapper, Version=13.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Delegate, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<.ctor>b1() at System.Lazy1[[System.Delegate, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ViaFactory(LazyThreadSafetyMode ) at System.Lazy1[[System.Delegate, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecutionAndPublication(LazyHelper , Boolean ) at System.Lazy1[[System.Delegate, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].CreateValue() at System.Lazy1[[System.Delegate, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].get_Value() at AutoMapper.Internal.LockingConcurrentDictionary2[[AutoMapper.Internal.MapRequest, AutoMapper, Version=13.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[System.Delegate, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(MapRequest& key) at AutoMapper.MapperConfiguration.GetExecutionPlan(MapRequest& mapRequest) at AutoMapper.MapperConfiguration.AutoMapper.Internal.IGlobalConfiguration.GetExecutionPlan[Object,Organisation](MapRequest& mapRequest) at AutoMapper.Mapper.MapCore[Object,Organisation](Object source, Organisation destination, ResolutionContext context, Type sourceType, Type destinationType, MemberMap memberMap) at AutoMapper.Mapper.Map[Object,Organisation](Object source, Organisation destination) at AutoMapper.Mapper.Map[Organisation](Object source) at MongoDBAppServices.MongoDBAppData.<ReadOrganisation>d__202[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[SharedCommon.Models.Authorisation.Organisation.Organisation, SharedCommon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()

sumowesley commented 2 weeks ago

I have the interpreter turned on to use Automapper with iOS, which works already. I've now turned it on for Mac, too, allowing me to run the app locally on the MacBook Air M1. I've created a new package for Mac and uploaded it to TestFlight. It works on both arm64 and x64 when deployed.

sumowesley commented 2 weeks ago

The mono interpreter seems like a blunt instrument. Short of hard coding the class mappings or turning on the interpreter, is there an alternative approach to explore?

drasticactions commented 2 weeks ago

@sumowesley I would ask Automapper how they would suggest handling AOT use cases like this and see if it has ways to. Otherwise, the path of least resistance would probably be to enable the Mono Interpreter. MAUI UI Debug builds enable the Interpreter by default (hence why you wouldn't see this until Release mode, non-MAUI UI .NET iOS/Mac Catalyst Template apps don't have it enabled in Debug mode)

I don't think this is a MAUI UI or, as far as I can see, a runtime one. You would either enable the Interpreter or use libraries/write code that play well with AOT. @rolfbjarne What do you think?

sumowesley commented 2 weeks ago

@drasticactions, that's a fair suggestion. I can't get over the fact that this worked on x64 with no interpreter active.

rolfbjarne commented 2 weeks ago

@drasticactions, that's a fair suggestion. I can't get over the fact that this worked on x64 with no interpreter active.

That's because there's no AOT compilation on x64, it's all JIT compilation, which works fine.

Note that you can fine tune the interpreter by enabling or disabling it on an assembly basis: https://learn.microsoft.com/en-us/dotnet/maui/macios/interpreter?view=net-maui-8.0

sumowesley commented 2 weeks ago

Hi @rolfbjarne , I'll explore the link you shared to see if I can get away with the interpreter in place for just AutoMapper

sumowesley commented 2 weeks ago

I'll close this one for now. Thanks to everybody for their help.