I am developing a React Native (0.45.0) application and once in a couple of hours my application crashes (or rather gets killed by watchdog) with 0x8badf00d. I understand why watchdog kills the application; the main thread takes longer than 20 seconds to respond to an event. But I have no idea how to debug this in React Native. Everything is in Javascript and in promises so I am assuming that the network execution that I am doing is already asynchronous.
The application seems to be only crashing while it's in the background. However, the crash reports role states Foreground. We are using background fetch and background geolocation which both do a network request. I have measured the time from event trigger to finish and it does not take longer than one second in total.
I read that the most common problem for this error to happen is a network request on the main threat. Could it be that it tries to load the js bundle synchronously and hangs? How can I debug this problem when all my code is in Javascript?
Thank you very much in advance.
Incident Identifier: 36E63A5F-7C40-40C0-9914-2C9EAE494C11
Beta Identifier: 3C432B54-1947-470E-A387-6566A494E145
Hardware Model: iPhone7,2
Process: [993]
Path: /private/var/containers/Bundle/Application/70B3363C-32E9-4D26-B6C6-DB51304D46C7/.app/
Identifier: org.reactjs.native.example.Test3
Version: 20 (1.4)
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: org.reactjs.native.example.Test3 [703]
Date/Time: 2017-07-17 21:31:33.1931 -0400
Launch Time: 2017-07-17 19:18:30.9574 -0400
OS Version: iPhone OS 10.3.2 (14F89)
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace <0xF>, Code 0x8badf00d
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib
0x0000000182a07224 0x182a06000 + 4644
1 libsystem_kernel.dylib
0x0000000182a0709c 0x182a06000 + 4252
2 CoreFoundation
0x00000001839d8e90 0x1838fe000 + 896656
3 CoreFoundation
0x00000001839d6ae4 0x1838fe000 + 887524
4 CoreFoundation
0x0000000183906da4 0x1838fe000 + 36260
5 GraphicsServices
0x0000000185370074 0x185364000 + 49268
6 UIKit
0x0000000189bc1058 0x189b4c000 + 479320
7
0x00000001000bfa08 0x1000b8000 + 31240
8 libdyld.dylib
0x000000018291559c 0x182911000 + 17820
Update, symbolized part of the crash log:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000182faf224 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000182faf09c mach_msg + 72
2 CoreFoundation 0x0000000183f80e90 __CFRunLoopServiceMachPort + 192
3 CoreFoundation 0x0000000183f7eae4 __CFRunLoopRun + 1060
4 CoreFoundation 0x0000000183eaeda4 CFRunLoopRunSpecific + 424
5 GraphicsServices 0x0000000185918074 GSEventRunModal + 100
6 UIKit 0x000000018a169058 UIApplicationMain + 208
7 0x0000000100063294 0x10005c000 + 29332
8 libdyld.dylib 0x0000000182ebd59c start + 4