ios – App freezes and crashes in AVCaptureVideoPreviewLayer layerDidBecomeVisible


I’ve a React Native app which is deployed on tablets. The app entails common interactions w/ the digital camera and I am utilizing Expo Digital camera to handle these interactions. I am seeing that prospects who’re operating this app on an iPad are intermittently seeing the app freeze (and in the end crash). Nevertheless, the stack traces do not present any apparent motive that’s inflicting the freeze

The hint signifies that the primary thread begins ready for a lock on one thing when it is attempting to do structure, but it surely’s not clear what the thread is ready on.

Additional, thread 15 exhibits that additionally it is attempting to replace the CALayer, which appears odd (I assumed UI updates needed to be on the primary thread).

Anybody have expertise with one thing related? Respect any insights on the way to debug, thanks!

Under is the uncooked stack hint 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>::subsequent
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 identify: 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   Basis                      0x3207c60c0         -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
8   Basis                      0x3207c5fa8         -[NSRunLoop(NSRunLoop) runUntilDate:]
9   UIKitCore                       0x330689da8         -[UIEventFetcher threadMain]
10  Basis                      0x3207df630         __NSThread__start__
11  libsystem_pthread.dylib         0x3e9e916b4         _pthread_start

Thread 2 identify: com.fb.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::Attempt<T>::throwUnlessValue
8   Basis                      0x3207df630         __NSThread__start__
9   libsystem_pthread.dylib         0x3e9e916b4         _pthread_start

Thread 3 identify: 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         fb::jsi::JSError::~JSError
4   hermes                          0x1027ffdf8         fb::jsi::JSError::~JSError
5   libsystem_pthread.dylib         0x3e9e916b4         _pthread_start

Thread 4 identify: 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         fb::hermes::inspector::element::Thread::run
5   libsystem_pthread.dylib         0x3e9e916b4         _pthread_start

Thread 5 identify: 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         fb::hermes::inspector::element::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 identify: 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 identify: SentryCrash Exception Handler (Major)
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 identify: 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   Basis                      0x3207df630         __NSThread__start__
6   libsystem_pthread.dylib         0x3e9e916b4         _pthread_start
7   libsystem_pthread.dylib         0x3e9e90b84         thread_start

Thread 10 identify: 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   Basis                      0x3207df630         __NSThread__start__
9   libsystem_pthread.dylib         0x3e9e916b4         _pthread_start

Thread 11 identify: com.apple.CFSocket.personal
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   Basis                      0x3207c01dc         NSKeyValueNotifyObserver
9   Basis                      0x3207d6724         NSKeyValueDidChange
10  Basis                      0x3207c3624         -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
11  Basis                      0x3207c3354         -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
12  Basis                      0x3207c2304         _NSSetLongLongValueAndNotify
13  <application_code>              0x2015f02c8         plcrash::PL_::async::dwarf_cfa_state_iterator<T>::subsequent
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 within the app, as a result of I suspected that the logging was transferring a considerable amount of information over the RN bridge and choking the interactions. I’ve additionally tried this answer that I discovered on StackOverflow, which did not make a distinction.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles