I have a React Native app which is deployed on tablets. The app involves regular interactions w/ the camera and I'm using Expo Camera to manage these interactions. I'm seeing that customers who are running this app on an iPad are intermittently seeing the app freeze (and ultimately crash). However, the stack traces don't show any obvious reason that is causing the freeze
The trace indicates that the main thread starts waiting for a lock on something when it's trying to do layout, but it's not clear what the thread is waiting on.
Further, thread 15 shows that it is also trying to update the CALayer, which seems odd (I thought UI updates had to be on the main thread).
Anyone have experience with something similar? Appreciate any insights on how to debug, thanks!
Below is the raw stack trace that I get from the crash logs:
Thread 0
0 libsystem_kernel.dylib 0x3a891d7bc __ulock_wait
1 libsystem_platform.dylib 0x3e9d6300c _os_unfair_lock_lock_slow
2 libobjc.A.dylib 0x31e333848 objc_sync_enter
3 AVFCapture 0x35f6a3704 -[AVCaptureVideoPreviewLayer layerDidBecomeVisible:]
4 QuartzCore 0x32eb2e8e8 CA::Layer::mark_visible
5 QuartzCore 0x32eba4c94 CA::Layer::update_added_sublayer
6 QuartzCore 0x32eb52398 CA::Layer::insert_sublayer
7 QuartzCore 0x32eb97008 -[CALayer insertSublayer:atIndex:]
8 <application_code> 0x2015ec8dc plcrash::PL_::async::dwarf_cfa_state_iterator<T>::next
9 UIKitCore 0x3301beef0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
10 QuartzCore 0x32eb2e4a8 CA::Layer::layout_if_needed
11 QuartzCore 0x32eb41a24 CA::Layer::layout_and_display_if_needed
12 QuartzCore 0x32eb52e50 CA::Context::commit_transaction
13 QuartzCore 0x32eb823bc CA::Transaction::commit
14 QuartzCore 0x32eb6c370 CA::Transaction::flush_as_runloop_observer
15 UIKitCore 0x3306b75f0 _UIApplicationFlushCATransaction
16 UIKitCore 0x330807dfc _UIUpdateSequenceRun
17 UIKitCore 0x330e6b940 schedulerStepScheduledMainSection
18 UIKitCore 0x330e6ae9c runloopSourceCallback
19 CoreFoundation 0x32c1b1204 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
20 CoreFoundation 0x32c1bd860 __CFRunLoopDoSource0
21 CoreFoundation 0x32c1426c4 __CFRunLoopDoSources0
22 CoreFoundation 0x32c1581c0 __CFRunLoopRun
23 CoreFoundation 0x32c15d4d8 CFRunLoopRunSpecific
24 GraphicsServices 0x3a14b9358 GSEventRunModal
25 UIKitCore 0x330557378 -[UIApplication _run]
26 UIKitCore 0x330556fdc UIApplicationMain
27 <application_code> 0x200fe98f0 <redacted>
Thread 1 name: com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x3a891cc84 mach_msg2_trap
1 libsystem_kernel.dylib 0x3a892fb50 mach_msg2_internal
2 libsystem_kernel.dylib 0x3a892fe28 mach_msg_overwrite
3 libsystem_kernel.dylib 0x3a891d1c4 mach_msg
4 CoreFoundation 0x32c157110 __CFRunLoopServiceMachPort
5 CoreFoundation 0x32c15833c __CFRunLoopRun
6 CoreFoundation 0x32c15d4d8 CFRunLoopRunSpecific
7 Foundation 0x3207c60c0 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
8 Foundation 0x3207c5fa8 -[NSRunLoop(NSRunLoop) runUntilDate:]
9 UIKitCore 0x330689da8 -[UIEventFetcher threadMain]
10 Foundation 0x3207df630 __NSThread__start__
11 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 2 name: com.facebook.react.JavaScript
0 libsystem_kernel.dylib 0x3a891cc84 mach_msg2_trap
1 libsystem_kernel.dylib 0x3a892fb50 mach_msg2_internal
2 libsystem_kernel.dylib 0x3a892fe28 mach_msg_overwrite
3 libsystem_kernel.dylib 0x3a891d1c4 mach_msg
4 CoreFoundation 0x32c157110 __CFRunLoopServiceMachPort
5 CoreFoundation 0x32c15833c __CFRunLoopRun
6 CoreFoundation 0x32c15d4d8 CFRunLoopRunSpecific
7 <application_code> 0x2012b5c88 folly::Try<T>::throwUnlessValue
8 Foundation 0x3207df630 __NSThread__start__
9 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 3 name: hades
0 libsystem_kernel.dylib 0x3a891d558 __psynch_cvwait
1 libsystem_pthread.dylib 0x3e9e98074 _pthread_cond_wait
2 libc++.1.dylib 0x348cf2ef4 std::__1::condition_variable::wait
3 hermes 0x1027ffec4 facebook::jsi::JSError::~JSError
4 hermes 0x1027ffdf8 facebook::jsi::JSError::~JSError
5 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 4 name: hermes-chrome-inspector-conn
0 libsystem_kernel.dylib 0x3a891d558 __psynch_cvwait
1 libsystem_pthread.dylib 0x3e9e98074 _pthread_cond_wait
2 libc++.1.dylib 0x348cf2ef4 std::__1::condition_variable::wait
3 <application_code> 0x2013b26cc folly::exception_wrapper::InPlace<T>::get_exception_ptr_
4 <application_code> 0x201373860 facebook::hermes::inspector::detail::Thread::run
5 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 5 name: hermes-inspector
0 libsystem_kernel.dylib 0x3a891d558 __psynch_cvwait
1 libsystem_pthread.dylib 0x3e9e98074 _pthread_cond_wait
2 libc++.1.dylib 0x348cf2ef4 std::__1::condition_variable::wait
3 <application_code> 0x2013b26cc folly::exception_wrapper::InPlace<T>::get_exception_ptr_
4 <application_code> 0x201373860 facebook::hermes::inspector::detail::Thread::run
5 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 6
0 libsystem_kernel.dylib 0x3a891d144 __semwait_signal
1 libsystem_c.dylib 0x33aaf3884 nanosleep
2 libsystem_c.dylib 0x33ab04b18 sleep
3 <application_code> 0x2013f4eb0 folly::exception_wrapper::InPlace<T>::get_exception_ptr_
4 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 7 name: SentryCrash Exception Handler (Secondary)
0 libsystem_kernel.dylib 0x3a891cc84 mach_msg2_trap
1 libsystem_kernel.dylib 0x3a892fb50 mach_msg2_internal
2 libsystem_kernel.dylib 0x3a8929860 thread_suspend
3 <application_code> 0x201400b60 __cxa_throw
4 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 8 name: SentryCrash Exception Handler (Primary)
0 libsystem_kernel.dylib 0x3a891cc84 mach_msg2_trap
1 libsystem_kernel.dylib 0x3a892fb50 mach_msg2_internal
2 libsystem_kernel.dylib 0x3a892fe28 mach_msg_overwrite
3 libsystem_kernel.dylib 0x3a891d1c4 mach_msg
4 <application_code> 0x201400b8c __cxa_throw
5 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 9 name: io.sentry.app-hang-tracker
0 <application_code> 0x201449494 __cxa_throw
1 <application_code> 0x20144ce50 __cxa_throw
2 <application_code> 0x2013e6204 folly::exception_wrapper::InPlace<T>::get_exception_ptr_
3 <application_code> 0x2013e59a8 folly::exception_wrapper::InPlace<T>::get_exception_ptr_
4 <application_code> 0x2013e5490 folly::exception_wrapper::InPlace<T>::get_exception_ptr_
5 Foundation 0x3207df630 __NSThread__start__
6 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
7 libsystem_pthread.dylib 0x3e9e90b84 thread_start
Thread 10 name: com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x3a891cc84 mach_msg2_trap
1 libsystem_kernel.dylib 0x3a892fb50 mach_msg2_internal
2 libsystem_kernel.dylib 0x3a892fe28 mach_msg_overwrite
3 libsystem_kernel.dylib 0x3a891d1c4 mach_msg
4 CoreFoundation 0x32c157110 __CFRunLoopServiceMachPort
5 CoreFoundation 0x32c15833c __CFRunLoopRun
6 CoreFoundation 0x32c15d4d8 CFRunLoopRunSpecific
7 CFNetwork 0x32e3587dc _CFURLStorageSessionDisableCache
8 Foundation 0x3207df630 __NSThread__start__
9 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 11 name: com.apple.CFSocket.private
0 libsystem_kernel.dylib 0x3a891d7e8 __select
1 CoreFoundation 0x32c1a6a78 __CFSocketManager
2 libsystem_pthread.dylib 0x3e9e916b4 _pthread_start
Thread 12
0 libsystem_kernel.dylib 0x3a891d18c __workq_kernreturn
1 libsystem_pthread.dylib 0x3e9e90e24 _pthread_wqthread
Thread 13
0 libsystem_kernel.dylib 0x3a891d18c __workq_kernreturn
1 libsystem_pthread.dylib 0x3e9e90e24 _pthread_wqthread
Thread 14
0 libsystem_kernel.dylib 0x3a891d18c __workq_kernreturn
1 libsystem_pthread.dylib 0x3e9e90e24 _pthread_wqthread
Thread 15
0 libsystem_kernel.dylib 0x3a891d7bc __ulock_wait
1 libsystem_platform.dylib 0x3e9d6300c _os_unfair_lock_lock_slow
2 QuartzCore 0x32eb66544 CA::Layer::thread_flags_
3 QuartzCore 0x32eb2e330 CA::Layer::layout_if_needed
4 QuartzCore 0x32eb41a24 CA::Layer::layout_and_display_if_needed
5 QuartzCore 0x32eb52e50 CA::Context::commit_transaction
6 QuartzCore 0x32eb823bc CA::Transaction::commit
7 AVFCapture 0x35f6fc214 -[AVCaptureVideoPreviewLayer observeValueForKeyPath:ofObject:change:context:]
8 Foundation 0x3207c01dc NSKeyValueNotifyObserver
9 Foundation 0x3207d6724 NSKeyValueDidChange
10 Foundation 0x3207c3624 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
11 Foundation 0x3207c3354 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
12 Foundation 0x3207c2304 _NSSetLongLongValueAndNotify
13 <application_code> 0x2015f02c8 plcrash::PL_::async::dwarf_cfa_state_iterator<T>::next
14 libdispatch.dylib 0x33aa6231c _dispatch_call_block_and_release
15 libdispatch.dylib 0x33aa63ea8 _dispatch_client_callout
16 libdispatch.dylib 0x33aa6b530 _dispatch_lane_serial_drain
17 libdispatch.dylib 0x33aa6c0a0 _dispatch_lane_invoke
18 libdispatch.dylib 0x33aa76cd8 _dispatch_workloop_worker_thread
19 libsystem_pthread.dylib 0x3e9e90dd8 _pthread_wqthread
Thread 16
0 libsystem_kernel.dylib 0x3a891d18c __workq_kernreturn
1 libsystem_pthread.dylib 0x3e9e90e24 _pthread_wqthread
I've disabled some heavy logging I had in the app, because I suspected that the logging was transferring a large amount of data over the RN bridge and choking the interactions. I've also tried this solution that I found on StackOverflow, which didn't make a difference.