azesmway / react-native-unity

MIT License
287 stars 74 forks source link

Crash on MacBook running the iOS app #125

Open entelostre opened 4 months ago

entelostre commented 4 months ago

Hello people, ONLY on MacBooks, I am having a crash the moment the UnityView should appear in my app. I spent some time to understand the issue without success so I am posting the Xcode log and the TestFlight crash report here in case anyone has some info. I am using react-native-unity v0.4.0 with a unity 2022.3.25f1 build.

An uncaught exception was raised
[KeyboardDelegate Initialize] called after creating keyboard
(
    0   CoreFoundation                      0x000000018127f2ec __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x0000000180d66788 objc_exception_throw + 60
    2   Foundation                          0x00000001823f242c -[NSCalendarDate initWithCoder:] + 0
    3   UnityFramework                      0x00000001123b3d44 +[KeyboardDelegate Initialize] + 112
    4   UnityFramework                      0x00000001123a92bc -[UnityAppController initUnityWithApplication:] + 912
    5   UnityFramework                      0x00000001123a8cfc -[UnityAppController application:didFinishLaunchingWithOptions:] + 384
    6   UnityFramework                      0x00000001123b1ac0 -[UnityFramework runEmbeddedWithArgc:argv:appLaunchOpts:] + 356
    7   kota                                0x00000001038db410 +[ReactNativeUnity launchWithOptions:] + 448
    8   kota                                0x00000001038db5c4 -[ReactNativeUnityView initWithFrame:] + 168
    9   kota                                0x00000001038dc1f0 -[ReactNativeUnityViewManager view] + 40
    10  kota                                0x000000010334c760 -[RCTComponentData createViewWithTag:rootTag:] + 284
    11  kota                                0x000000010341a41c __50-[RCTUIManager createView:viewName:rootTag:props:]_block_invoke + 88
    12  kota                                0x0000000103423a64 __RCTExecuteOnMainQueue_block_invoke + 40
    13  libdispatch.dylib                   0x000000010802cf2c _dispatch_call_block_and_release + 32
    14  libdispatch.dylib                   0x000000010802eba4 _dispatch_client_callout + 20
    15  libdispatch.dylib                   0x0000000108041f08 _dispatch_main_queue_drain + 1100
    16  libdispatch.dylib                   0x0000000108041aac _dispatch_main_queue_callback_4CF + 44
    17  CoreFoundation                      0x000000018124bad4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
    18  CoreFoundation                      0x0000000181209258 __CFRunLoopRun + 1996
    19  CoreFoundation                      0x0000000181208434 CFRunLoopRunSpecific + 608
    20  HIToolbox                           0x000000018b9ac19c RunCurrentEventLoopInMode + 292
    21  HIToolbox                           0x000000018b9abfd8 ReceiveNextEventCommon + 648
    22  HIToolbox                           0x000000018b9abd30 _BlockUntilNextEventMatchingListInModeWithFilter + 76
    23  AppKit                              0x0000000184a67d68 _DPSNextEvent + 660
    24  AppKit                              0x000000018525d808 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
    25  AppKit                              0x0000000184a5b09c -[NSApplication run] + 476
    26  AppKit                              0x0000000184a322e0 NSApplicationMain + 880
    27  AppKit                              0x0000000184c85a30 +[NSWindow _savedFrameFromString:] + 0
    28  UIKitMacHelper                      0x000000019a4d2f40 UINSApplicationMain + 972
    29  UIKitCore                           0x00000001b065f570 UIApplicationMain + 148
    30  kota                                0x00000001026b3ae0 main + 100
    31  dyld                                0x0000000180da20e0 start + 2360
)
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: 931D0E3F-1BB3-4E76-8D55-634FB3C78B65
Beta Identifier:     E7255B3A-9F6B-517B-BE53-DA55391C1E9C
Hardware Model:      MacBookAir10,1
Process:             kota [27727]
Path:                /Volumes/VOLUME/*/kota.app/kota
Identifier:          com.xixixo.kota
Version:             2.10.0 (9)
AppStoreTools:       15F31e
AppVariant:          1:MacFamily20,1:17
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.xixixo.kota [4399]

Date/Time:           2024-07-08 18:28:51.5451 +0300
Launch Time:         2024-07-08 11:01:32.3467 +0300
OS Version:          macOS 14.1.1 (23B81)
Release Type:        User
Report Version:      104

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

Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                         0x18b86e7f4 __exceptionPreprocess + 164
1   libobjc.A.dylib                        0x18b365eb4 objc_exception_throw + 60
2   Foundation                             0x18c9b547c -[NSCalendarDate initWithCoder:] + 0
3   UnityFramework                         0x1076045f0 0x1075f0000 + 83440
4   UnityFramework                         0x1075feff8 0x1075f0000 + 61432
5   UnityFramework                         0x1075fed50 0x1075f0000 + 60752
6   UnityFramework                         0x107603108 0x1075f0000 + 78088
7   kota                                   0x101530e54 0x100ac0000 + 10948180
8   kota                                   0x101530f98 0x100ac0000 + 10948504
9   kota                                   0x101531794 0x100ac0000 + 10950548
10  kota                                   0x1013186d4 0x100ac0000 + 8750804
11  kota                                   0x101361604 0x100ac0000 + 9049604
12  libdispatch.dylib                      0x18b56dcb8 _dispatch_call_block_and_release + 32
13  libdispatch.dylib                      0x18b56f910 _dispatch_client_callout + 20
14  libdispatch.dylib                      0x18b57dfa8 _dispatch_main_queue_drain + 984
15  libdispatch.dylib                      0x18b57dbc0 _dispatch_main_queue_callback_4CF + 44
16  CoreFoundation                         0x18b83b15c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
17  CoreFoundation                         0x18b7f8a80 __CFRunLoopRun + 1996
18  CoreFoundation                         0x18b7f7c5c CFRunLoopRunSpecific + 608
19  HIToolbox                              0x195d74448 RunCurrentEventLoopInMode + 292
20  HIToolbox                              0x195d74284 ReceiveNextEventCommon + 648
21  HIToolbox                              0x195d73fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
22  AppKit                                 0x18efd2c54 _DPSNextEvent + 660
23  AppKit                                 0x18f7a8ebc -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
24  AppKit                                 0x18efc6100 -[NSApplication run] + 476
25  AppKit                                 0x18ef9d3cc NSApplicationMain + 880
26  AppKit                                 0x18f1f0240 +[NSWindow _savedFrameFromString:] + 0
27  UIKitMacHelper                         0x1a43a7d8c UINSApplicationMain + 972
28  UIKitCore                              0x1b9d3793c UIApplicationMain + 148
29  kota                                   0x100ac6334 0x100ac0000 + 25396
30  dyld                                   0x18b3a10e0 start + 2360

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   AppKit                                 0x18f2ae3fc -[NSApplication _crashOnException:] + 240
1   AppKit                                 0x18f2ae1d4 -[NSApplication reportException:] + 440
2   AppKit                                 0x18f3f8558 NSApplicationUncaughtExceptionHandler + 152
3   UnityFramework                         0x107606b20 0x1075f0000 + 92960
4   CoreFoundation                         0x18b912f64 __handleUncaughtException + 800
5   libobjc.A.dylib                        0x18b36f888 _objc_terminate() + 132
6   kota                                   0x101047024 0x100ac0000 + 5795876
7   libc++abi.dylib                        0x18b6d3a9c std::__terminate(void (*)()) + 16
8   libc++abi.dylib                        0x18b6d3a40 std::terminate() + 56
9   libdispatch.dylib                      0x18b56f924 _dispatch_client_callout + 40
10  libdispatch.dylib                      0x18b57dfa8 _dispatch_main_queue_drain + 984
11  libdispatch.dylib                      0x18b57dbc0 _dispatch_main_queue_callback_4CF + 44
12  CoreFoundation                         0x18b83b15c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
13  CoreFoundation                         0x18b7f8a80 __CFRunLoopRun + 1996
14  CoreFoundation                         0x18b7f7c5c CFRunLoopRunSpecific + 608
15  HIToolbox                              0x195d74448 RunCurrentEventLoopInMode + 292
16  HIToolbox                              0x195d74284 ReceiveNextEventCommon + 648
17  HIToolbox                              0x195d73fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
18  AppKit                                 0x18efd2c54 _DPSNextEvent + 660
19  AppKit                                 0x18f7a8ebc -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
20  AppKit                                 0x18efc6100 -[NSApplication run] + 476
21  AppKit                                 0x18ef9d3cc NSApplicationMain + 880
22  AppKit                                 0x18f1f0240 _NSApplicationMainWithInfoDictionary + 24
23  UIKitMacHelper                         0x1a43a7d8c UINSApplicationMain + 972
24  UIKitCore                              0x1b9d3793c UIApplicationMain + 148
25  kota                                   0x100ac6334 0x100ac0000 + 25396
26  dyld                                   0x18b3a10e0 start + 2360

Thread 1:: com.apple.uikit.eventfetch-thread
0   libsystem_kernel.dylib                 0x18b6dc8b4 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x18b6eed30 mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x18b6e54f0 mach_msg_overwrite + 476
3   libsystem_kernel.dylib                 0x18b6dcc38 mach_msg + 24
4   CoreFoundation                         0x18b7f9ea4 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x18b7f876c __CFRunLoopRun + 1208
6   CoreFoundation                         0x18b7f7c5c CFRunLoopRunSpecific + 608
7   Foundation                             0x18c900a78 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8   Foundation                             0x18c9753f0 -[NSRunLoop(NSRunLoop) runUntilDate:] + 100
9   UIKitCore                              0x1b9d38d08 -[UIEventFetcher threadMain] + 104
10  Foundation                             0x18c8f9ff4 __NSThread__start__ + 716
11  libsystem_pthread.dylib                0x18b71d034 _pthread_start + 136
12  libsystem_pthread.dylib                0x18b717e3c thread_start + 8

Thread 2:: com.apple.NSEventThread
0   libsystem_kernel.dylib                 0x18b6dc8b4 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x18b6eed30 mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x18b6e54f0 mach_msg_overwrite + 476
3   libsystem_kernel.dylib                 0x18b6dcc38 mach_msg + 24
4   CoreFoundation                         0x18b7f9ea4 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x18b7f876c __CFRunLoopRun + 1208
6   CoreFoundation                         0x18b7f7c5c CFRunLoopRunSpecific + 608
7   AppKit                                 0x18f0fc404 _NSEventThread + 144
8   libsystem_pthread.dylib                0x18b71d034 _pthread_start + 136
9   libsystem_pthread.dylib                0x18b717e3c thread_start + 8

Thread 3:: com.google.firebase.crashlytics.MachExceptionServer
0   libsystem_kernel.dylib                 0x18b6e03d4 write + 8
1   kota                                   0x10104d62c 0x100ac0000 + 5821996
2   kota                                   0x10104f1ac 0x100ac0000 + 5829036
3   libsystem_pthread.dylib                0x18b71d034 _pthread_start + 136
4   libsystem_pthread.dylib                0x18b717e3c thread_start + 8

Thread 4:: com.facebook.react.JavaScript
0   hermes                                 0x102561fb4 0x102518000 + 303028
1   hermes                                 0x10255f2b4 0x102518000 + 291508
2   hermes                                 0x102541018 0x102518000 + 167960
3   hermes                                 0x1025407ac 0x102518000 + 165804
4   hermes                                 0x10255fdc4 0x102518000 + 294340
5   hermes                                 0x10255f2b4 0x102518000 + 291508
6   hermes                                 0x102541018 0x102518000 + 167960
7   hermes                                 0x10253f860 0x102518000 + 161888
8   hermes                                 0x10260e8e4 0x102518000 + 1009892
9   hermes                                 0x102540d70 0x102518000 + 167280
10  hermes                                 0x10255fda8 0x102518000 + 294312
11  hermes                                 0x10255f2b4 0x102518000 + 291508
12  hermes                                 0x102541018 0x102518000 + 167960
13  hermes                                 0x10253f860 0x102518000 + 161888
14  hermes                                 0x10260e8e4 0x102518000 + 1009892
15  hermes                                 0x102540d70 0x102518000 + 167280
16  hermes                                 0x10255fda8 0x102518000 + 294312
17  hermes                                 0x10255f2b4 0x102518000 + 291508
18  hermes                                 0x102541018 0x102518000 + 167960
19  hermes                                 0x1025407ac 0x102518000 + 165804
20  hermes                                 0x102525dd4 0x102518000 + 56788
21  kota                                   0x10158bf48 0x100ac0000 + 11321160
22  kota                                   0x1014dd88c 0x100ac0000 + 10606732
23  kota                                   0x1014dd6f8 0x100ac0000 + 10606328
24  kota                                   0x10132d8d8 0x100ac0000 + 8837336
25  kota                                   0x1014da888 0x100ac0000 + 10594440
26  kota                                   0x1014705f0 0x100ac0000 + 10159600
27  kota                                   0x101330d30 0x100ac0000 + 8850736
28  kota                                   0x10133be10 0x100ac0000 + 8896016
29  kota                                   0x10133bbdc 0x100ac0000 + 8895452
30  CoreFoundation                         0x18b7f9894 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
31  CoreFoundation                         0x18b7f97a8 __CFRunLoopDoBlocks + 356
32  CoreFoundation                         0x18b7f8c3c __CFRunLoopRun + 2440
33  CoreFoundation                         0x18b7f7c5c CFRunLoopRunSpecific + 608
34  kota                                   0x101325ce8 0x100ac0000 + 8805608
35  Foundation                             0x18c8f9ff4 __NSThread__start__ + 716
36  libsystem_pthread.dylib                0x18b71d034 _pthread_start + 136
37  libsystem_pthread.dylib                0x18b717e3c thread_start + 8

Thread 5:: hades
0   libsystem_kernel.dylib                 0x18b6e00ac __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x18b71d5fc _pthread_cond_wait + 1228
2   libc++.1.dylib                         0x18b6484dc std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   hermes                                 0x1026343f8 0x102518000 + 1164280
4   hermes                                 0x1026341ac 0x102518000 + 1163692
5   libsystem_pthread.dylib                0x18b71d034 _pthread_start + 136
6   libsystem_pthread.dylib                0x18b717e3c thread_start + 8

Thread 6:: hermes-chrome-inspector-conn
0   libsystem_kernel.dylib                 0x18b6e00ac __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x18b71d5fc _pthread_cond_wait + 1228
2   libc++.1.dylib                         0x18b6484dc std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   kota                                   0x1015b58d0 0x100ac0000 + 11491536
4   kota                                   0x101575354 0x100ac0000 + 11227988
5   libsystem_pthread.dylib                0x18b71d034 _pthread_start + 136
6   libsystem_pthread.dylib                0x18b717e3c thread_start + 8

Thread 7:: hermes-inspector
0   libsystem_kernel.dy...
angelos3lex commented 4 months ago

Indeed, this is happening when running the unity view of my RN app, on mac with M1 chip. @entelostre Do you know if this is happening on m2 too?

entelostre commented 4 months ago

Indeed, this is happening when running the unity view of my RN app, on mac with M1 chip. @entelostre Do you know if this is happening on m2 too?

Yes this is happening both on m1 and m2.

angelos3lex commented 4 months ago
An uncaught exception was raised
[KeyboardDelegate Initialize] called after creating keyboard

@azesmway Could this be related to the fact that we don't set the app's launch options to the unity controller? I see in RNUnityView.mm that you do [[self ufw] runEmbeddedWithArgc: gArgc argv: array appLaunchOpts: appLaunchOpts]; but the appLaunchOpts is empty, not the ones of the app's that exist in the app's AppDelegate.mm. Do you think we can pass these options to the unity view? Would this be relevant?

azesmway commented 4 months ago
An uncaught exception was raised
[KeyboardDelegate Initialize] called after creating keyboard

@azesmway Could this be related to the fact that we don't set the app's launch options to the unity controller? I see in RNUnityView.mm that you do [[self ufw] runEmbeddedWithArgc: gArgc argv: array appLaunchOpts: appLaunchOpts]; but the appLaunchOpts is empty, not the ones of the app's that exist in the app's AppDelegate.mm. Do you think we can pass these options to the unity view? Would this be relevant?

Hi. You have to read the Unity documentation, I don't know.

entelostre commented 4 months ago

Thanks for the reply @azesmway it's ok.

I solved this by commenting out this line: [KeyboardDelegate Initialize] in UnityAppController.mm