App crashed on launch only on some devices (passed App Store review)

My app has been approved by Apple and is available on the App Store. However, it crashes on launch on some devices, while most of the other devices work fine.

We've tried many things but still can't figure out the problem and also can't reproduce it. If you have any insights or suggestions on how we can proceed, please let us know, thanks!

Some details that may help in identifying the issue

  1. App crashes on launch on some devices, but most devices work without issues.
  2. Issue reported in Singapore and Thailand, but not specific to the region as some other apps in those countries work well.
  3. One user experiencing the issue was on the same WiFi network as another user without the issue, suggesting that it was not a network-related problem.
  4. Sentry has been installed to catch errors but didn't detect any error when the app crashed on launch. This indicates that the issue may be happening before Sentry launches.
  5. Devices crashing are iPhone 13 (iOS 16.3, iOS 16.4) and iPhone 13 Pro (iOS 16.2). Tests on AWS Device Farm with iPhone 13 (iOS 16.0.2) and iPhone 13 Pro (iOS 15.2) (the only iOS versions supported) passed, suggesting that it's not a device-specific issue.

Other information

  • The app is developed by React Native (version 0.70.5), using the Expo framework (Expo SDK 47)
  • The app is built by EAS CLI (version 3.10.0) (Expo Application Services)

iOS crash log with the crashing thread

Incident Identifier: 8B7F4A8D-E32F-4BAE-AAFB-D0F780929694
CrashReporter Key:   ee432b7f594204dc754625e19ef274943345c9b1
Hardware Model:      iPhone14,2
Process:             MyApp [834]
Path:                /private/var/containers/Bundle/Application/87D1B99A-5144-426A-BB71-301F43FD507E/MyApp.app/MyApp
Identifier:          com.company.myapp
Version:             1.0.0 (166)
AppStoreTools:       14C17
AppVariant:          1:iPhone14,2:15
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.company.myapp [854]

Date/Time:           2023-04-16 10:54:07.0894 +0800
Launch Time:         2023-04-16 10:54:06.4107 +0800
OS Version:          iPhone OS 16.3 (20D47)
Release Type:        User
Baseband Version:    2.40.01
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  4

Application Specific Information:
abort() called

Thread 4 name:   Dispatch queue: expo.controller.errorRecoveryQueue
Thread 4 Crashed:
0   libsystem_kernel.dylib        	       0x20a827674 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x21af8b1ac pthread_kill + 268
2   libsystem_c.dylib             	       0x1d4388c8c abort + 180
3   libc++abi.dylib               	       0x21aecab8c abort_message + 132
4   libc++abi.dylib               	       0x21aebaa80 demangling_terminate_handler() + 336
5   libobjc.A.dylib               	       0x1c5ea1d3c _objc_terminate() + 144
6   libc++abi.dylib               	       0x21aec9f28 std::__terminate(void (*)()) + 20
7   libc++abi.dylib               	       0x21aec9ec4 std::terminate() + 56
8   libdispatch.dylib             	       0x1d4324f9c _dispatch_client_callout + 40
9   libdispatch.dylib             	       0x1d432c640 _dispatch_lane_serial_drain + 672
10  libdispatch.dylib             	       0x1d432d18c _dispatch_lane_invoke + 384
11  libdispatch.dylib             	       0x1d4337e10 _dispatch_workloop_worker_thread + 652
12  libsystem_pthread.dylib       	       0x21af84df8 _pthread_wqthread + 288
13  libsystem_pthread.dylib       	       0x21af84b98 start_wqthread + 8

Full crash log

Consider this snippet from crash-log-1.txt:

Last Exception Backtrace:
0   CoreFoundation          … __exceptionPreprocess + 164
1   libobjc.A.dylib         … objc_exception_throw + 60
2   MyApp                   … 0x102654000 + 616128
3   MyApp                   … 0x102654000 + 687236
4   MyApp                   … 0x102654000 + 685260
5   libdispatch.dylib       … _dispatch_call_block_and_release + 32
6   libdispatch.dylib       … _dispatch_client_callout + 20
7   libdispatch.dylib       … _dispatch_lane_serial_drain + 672
8   libdispatch.dylib       … _dispatch_lane_invoke + 384
9   libdispatch.dylib       … _dispatch_workloop_worker_thread + 652
10  libsystem_pthread.dylib … _pthread_wqthread + 288
11  libsystem_pthread.dylib … start_wqthread + 8

Your app has died to an unhandled language exception. Frame 1 shows that the exception was throw by your code in frame 2. To make progress you’ll need to symbolicate these logs to uncover the identity of the code in frames 4 through 2. See Adding Identifiable Symbol Names to a Crash Report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

After several hours of debugging, I found out that it was because we were passing a non-ISO date string to the Javascript new Date() object. It works for some of the devices (Javascript runtime) but didn't work for all of them. And we make this call at a global level so it's causing the entire ReactNative app to crash.

new Date("2023-01-01") // Invalid for SOME devices (Javascript runtime)

new Date("2023-01-01T00:00:00.000Z") // ISO date string valid for all devices

My reading of the docs [1] is that the Date constructor defers to Date.parse() which is only guaranteed to support that second format:

Other formats may be used, but results are implementation-dependent.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

App crashed on launch only on some devices (passed App Store review)
 
 
Q