Skip to content

馃悰 [iOS] Sharing one output between two CameraSession's aborts in [AVCaptureOutput detachFromFigCaptureSession:]#4156

Description

@Regina-v

Prerequisites

Reproduction

https://github.com/Regina-v/legendary-potato

Steps to reproduce

  1. Clone repo https://github.com/Regina-v/legendary-potato
  2. Build the app
npm install
cd ios && bundle install && bundle exec pod install
  1. Run on a real iPhone

  2. Tap one of the two buttons, both of which abort:

  3. Imperative (src/runImperativeRepro.ts): Creates one CameraFrameOutput, configures session_#1 with it, tears session_#1 down with stop() + configure([]), configures session_#2 with the same output, then releases session_#1 and allocates to force the Hermes GC to finalize it.

  4. Declarative (src/DeclarativeRepro.tsx): This repro is more similar to our app. We are using the barcode scanner as output and have the barcode processing logic defined in a hook. The <Camera> is unmounted after each barcode scan while the screen which holds the barcode processor hook and the <Camera> stays mounted in the stack. This repro has the same structure as our app: the CameraFrameOutput is created by a component that stays mounted while we unmount/remount the <Camera> on a timer as it happens in our app which only renders the <Camera> while focused and in the forgreound. This one depends on GC timing, so it can take several remount cycles.

  5. App crashes with

Assertion failed: (figCaptureSession == _outputInternal->figCaptureSession),
function -[AVCaptureOutput detachFromFigCaptureSession:]_block_invoke,
file AVCaptureOutput.m, line 333.

What did you expect to happen?

The app stays alive as it did with react-native-vision-camera v4.

What actually happened?

The app crashes with SIGBART ABORT.

Affected platforms

iOS (device)

Device(s) affected

iPhone 12 mini (iOS 27 Beta 5), iPhone 14 (iOS 26.5.2), iPhone 13 (iOS 26.5.2)

VisionCamera version

5.2.2

React Native version

0.86.0

React Native architecture

New Architecture (Fabric / bridgeless)

Features being used

  • Preview
  • Photo capture
  • Video capture
  • Frame Processors (worklets)
  • Skia Frame Processors
  • Code/Barcode Scanner
  • Location metadata
  • Multi-cam
  • Depth data
  • HDR / custom dynamic range
  • Custom format / FPS / resolution

Relevant logs / stack trace

thread #1, queue = 'com.apple.main-thread'
    frame #0: 0x00000002450c9cd4 libsystem_kernel.dylib`mach_msg2_trap + 8
    frame #1: 0x00000002450cd308 libsystem_kernel.dylib`mach_msg2_internal + 76
    frame #2: 0x00000002450cd228 libsystem_kernel.dylib`mach_msg_overwrite + 424
    frame #3: 0x00000002450cd074 libsystem_kernel.dylib`mach_msg + 24
    frame #4: 0x000000018e3921d4 CoreFoundation`__CFRunLoopServiceMachPort + 136
    frame #5: 0x000000018e3911fc CoreFoundation`__CFRunLoopRun + 824
    frame #6: 0x000000018e39255c CoreFoundation`_CFRunLoopRunSpecificWithOptions + 344
    frame #7: 0x0000000237c71f24 GraphicsServices`GSEventRunModal + 120
    frame #8: 0x0000000192564668 UIKitCore`UIApplicationMain + 336
    frame #9: 0x000000019280d090 UIKitCore`___lldb_unnamed_symbol_184ab1028 + 104
    frame #12: 0x0000000104939b40 LegendaryPotato.debug.dylib`main at <compiler-generated>:0
    frame #13: 0x000000018e1e3630 dyld`start + 6616
  thread #15
    frame #0: 0x000000018e296908 libsystem_pthread.dylib`start_wqthread
* thread #19, name = 'com.facebook.react.runtime.JavaScript', queue = 'capture.output.FigCaptureSessionSyncQueue', stop reason = signal SIGABRT
    frame #0: 0x00000002450d41fc libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x000000018e29d458 libsystem_pthread.dylib`pthread_kill + 268
    frame #2: 0x0000000195b74838 libsystem_c.dylib`abort + 148
    frame #3: 0x0000000195b73cac libsystem_c.dylib`__assert_rtn + 284
    frame #4: 0x00000001bb57e018 AVFCapture`__47-[AVCaptureOutput detachFromFigCaptureSession:]_block_invoke.cold.1 + 44
    frame #5: 0x00000001bb473b94 AVFCapture`__47-[AVCaptureOutput detachFromFigCaptureSession:]_block_invoke + 112
    frame #6: 0x0000000102f39e5c libdispatch.dylib`_dispatch_client_callout + 16
    frame #7: 0x0000000102f30f7c libdispatch.dylib`_dispatch_lane_barrier_sync_invoke_and_complete + 172
    frame #8: 0x00000001bb473c20 AVFCapture`-[AVCaptureOutput detachFromFigCaptureSession:] + 140
    frame #9: 0x000000018e482f54 CoreFoundation`-[NSSet makeObjectsPerformSelector:withObject:] + 188
    frame #10: 0x00000001bb4383a4 AVFCapture`-[AVCaptureSession _makeConfigurationLive:] + 116
    frame #11: 0x00000001bb4735a8 AVFCapture`-[AVCaptureSession dealloc] + 356
    frame #12: 0x0000000104e36ad4 LegendaryPotato.debug.dylib`HybridCameraSession.deinit() at HybridCameraSession.swift:0
    frame #13: 0x0000000104e36b00 LegendaryPotato.debug.dylib`HybridCameraSession.__deallocating_deinit() at HybridCameraSession.swift:0
    frame #14: 0x000000018f911c30 libswiftCore.dylib`_swift_release_dealloc + 64
    frame #15: 0x000000018f910938 libswiftCore.dylib`bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 240
    frame #16: 0x0000000104e3ed48 LegendaryPotato.debug.dylib`HybridCameraSessionSpec_cxx.deinit() at HybridCameraSessionSpec_cxx.swift:0
    frame #17: 0x0000000104e3ed7c LegendaryPotato.debug.dylib`HybridCameraSessionSpec_cxx.__deallocating_deinit() at HybridCameraSessionSpec_cxx.swift:0
    frame #18: 0x000000018f911c30 libswiftCore.dylib`_swift_release_dealloc + 64
    frame #19: 0x000000018f910938 libswiftCore.dylib`bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 240
  * frame #20: 0x00000001049d00b4 LegendaryPotato.debug.dylib`swift::_impl::RefCountedClass::~RefCountedClass(this=0x0000000144067d60) at _SwiftCxxInteroperability.h:186:43
    frame #21: 0x0000000104cfcd84 LegendaryPotato.debug.dylib`VisionCamera::HybridCameraSessionSpec_cxx::~HybridCameraSessionSpec_cxx(this=0x0000000144067d60) at VisionCamera-Swift.h:12804:67
    frame #22: 0x0000000104cf4d0c LegendaryPotato.debug.dylib`VisionCamera::HybridCameraSessionSpec_cxx::~HybridCameraSessionSpec_cxx(this=0x0000000144067d60) at VisionCamera-Swift.h:12804:67
    frame #23: 0x0000000104d07a24 LegendaryPotato.debug.dylib`margelo::nitro::camera::HybridCameraSessionSpecSwift::~HybridCameraSessionSpecSwift(this=0x0000000144067d58, vtt=0x000000010507aab8) at HybridCameraSessionSpecSwift.hpp:113:9
    frame #24: 0x0000000104d06cd4 LegendaryPotato.debug.dylib`margelo::nitro::camera::HybridCameraSessionSpecSwift::~HybridCameraSessionSpecSwift(this=0x0000000144067d58) at HybridCameraSessionSpecSwift.hpp:113:9
    frame #26: 0x0000000104d07da0 LegendaryPotato.debug.dylib`void std::__1::allocator_traits<std::__1::allocator<margelo::nitro::camera::HybridCameraSessionSpecSwift>>::destroy[abi:dee210106]<margelo::nitro::camera::HybridCameraSessionSpecSwift, 0>((null)=0x000000016e560917, __p=0x0000000144067d58) at allocator_traits.h:313:5
    frame #28: 0x0000000104d06a1c LegendaryPotato.debug.dylib`std::__1::__shared_ptr_emplace<margelo::nitro::camera::HybridCameraSessionSpecSwift, std::__1::allocator<margelo::nitro::camera::HybridCameraSessionSpecSwift>>::__on_zero_shared(this=0x0000000144067d40) at shared_ptr.h:184:78
    frame #29: 0x0000000103c14c6c hermesvm`facebook::hermes::deleteShared(hermes::vm::HadesGC&, hermes::vm::NativeState*) + 88
    frame #30: 0x0000000103e21478 hermesvm`hermes::vm::HadesGC::youngGenCollection(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, bool) + 904
    frame #31: 0x0000000103e24de8 hermesvm`void* hermes::vm::HadesGC::allocSlow<(hermes::vm::CanBeLarge)1, (hermes::vm::MayFail)1>(unsigned int) + 184
    frame #32: 0x0000000103d71240 hermesvm`hermes::vm::ArrayStorageBase<hermes::vm::SmallHermesValueAdaptor>* hermes::vm::HadesGC::makeASlowCanBeLarge<hermes::vm::ArrayStorageBase<hermes::vm::SmallHermesValueAdaptor>, (hermes::vm::HasFinalizer)0, (hermes::vm::MayFail)1>(unsigned int) + 44
    frame #33: 0x0000000103e61a84 hermesvm`hermes::vm::ArrayStorageBase<hermes::vm::SmallHermesValueAdaptor>::create(hermes::vm::Runtime&, unsigned int) + 192
    frame #34: 0x0000000103e61b1c hermesvm`hermes::vm::ArrayStorageBase<hermes::vm::SmallHermesValueAdaptor>::reallocateToLarger(hermes::vm::MutableHandle<hermes::vm::ArrayStorageBase<hermes::vm::SmallHermesValueAdaptor>>, hermes::vm::Runtime&, unsigned int, unsigned int, unsigned int, unsigned int) + 40
    frame #35: 0x0000000103e663f0 hermesvm`hermes::vm::ArrayImpl::_setOwnIndexedImpl(hermes::vm::Handle<hermes::vm::JSObject>, hermes::vm::Runtime&, unsigned int, hermes::vm::Handle<hermes::vm::HermesValue>) + 508
    frame #36: 0x0000000103e695ac hermesvm`hermes::vm::JSObject::putComputedWithReceiver_RJS(hermes::vm::Handle<hermes::vm::JSObject>, hermes::vm::Runtime&, hermes::vm::Handle<hermes::vm::HermesValue>, hermes::vm::Handle<hermes::vm::HermesValue>, hermes::vm::Handle<hermes::vm::HermesValue>, hermes::vm::PropOpFlags) + 788
    frame #37: 0x0000000103e76f74 hermesvm`hermes::vm::arrayPrototypeFill(void*, hermes::vm::Runtime&) + 400
    frame #38: 0x0000000103d8dc9c hermesvm`hermes::vm::Interpreter::handleCallSlowPath(hermes::vm::Runtime&, hermes::vm::PinnedHermesValue*) + 164
    frame #39: 0x0000000103d8fe54 hermesvm`hermes::vm::CallResult<hermes::vm::HermesValue, (hermes::vm::detail::CallResultSpecialize)2> hermes::vm::Interpreter::interpretFunction<false, false>(hermes::vm::Runtime&, hermes::vm::InterpreterState&) + 8412
    frame #40: 0x0000000103e6486c hermesvm`hermes::vm::Runtime::interpretFunctionImpl(hermes::vm::CodeBlock*) + 132
    frame #41: 0x0000000103d76f50 hermesvm`hermes::vm::JSFunction::_callImpl(hermes::vm::Handle<hermes::vm::Callable>, hermes::vm::Runtime&) + 32
    frame #42: 0x0000000103d75b70 hermesvm`hermes::vm::Callable::executeCall2(hermes::vm::Handle<hermes::vm::Callable>, hermes::vm::Runtime&, hermes::vm::Handle<hermes::vm::HermesValue>, hermes::vm::HermesValue, hermes::vm::HermesValue, bool) + 172
    frame #43: 0x0000000103e7999c hermesvm`hermes::vm::generatorPrototypeResume(void*, hermes::vm::Runtime&) + 196
    frame #44: 0x0000000103d8dc9c hermesvm`hermes::vm::Interpreter::handleCallSlowPath(hermes::vm::Runtime&, hermes::vm::PinnedHermesValue*) + 164
    frame #45: 0x0000000103d8fe54 hermesvm`hermes::vm::CallResult<hermes::vm::HermesValue, (hermes::vm::detail::CallResultSpecialize)2> hermes::vm::Interpreter::interpretFunction<false, false>(hermes::vm::Runtime&, hermes::vm::InterpreterState&) + 8412
    frame #46: 0x0000000103e6486c hermesvm`hermes::vm::Runtime::interpretFunctionImpl(hermes::vm::CodeBlock*) + 132
    frame #47: 0x0000000103d76f50 hermesvm`hermes::vm::JSFunction::_callImpl(hermes::vm::Handle<hermes::vm::Callable>, hermes::vm::Runtime&) + 32
    frame #48: 0x0000000103d75954 hermesvm`hermes::vm::Callable::executeCall0(hermes::vm::Handle<hermes::vm::Callable>, hermes::vm::Runtime&, hermes::vm::Handle<hermes::vm::HermesValue>, bool) + 160
    frame #49: 0x0000000103dc1bd0 hermesvm`hermes::vm::Runtime::drainJobs() + 148
    frame #50: 0x0000000103c060e8 hermesvm`facebook::hermes::(anonymous namespace)::HermesRuntimeImpl::drainMicrotasks(int) + 40
    frame #51: 0x000000010b07818c React`facebook::react::RuntimeScheduler_Modern::performMicrotaskCheckpoint(facebook::jsi::Runtime&) + 172
    frame #52: 0x000000010b077f70 React`facebook::react::RuntimeScheduler_Modern::runEventLoopTick(facebook::jsi::Runtime&, facebook::react::Task&) + 272
    frame #53: 0x000000010b077c50 React`facebook::react::RuntimeScheduler_Modern::runEventLoop(facebook::jsi::Runtime&) + 188
    frame #54: 0x000000010b081844 React`facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0::operator()(facebook::jsi::Runtime&) const + 36
    frame #55: 0x000000010b081814 React`decltype(std::declval<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0&>()(std::declval<facebook::jsi::Runtime&>())) std::__1::__invoke[abi:de190102]<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0&, facebook::jsi::Runtime&>(facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0&, facebook::jsi::Runtime&) + 32
    frame #56: 0x000000010b0817c4 React`void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:de190102]<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0&, facebook::jsi::Runtime&>(facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0&, facebook::jsi::Runtime&) + 32
    frame #57: 0x000000010b081798 React`std::__1::__function::__alloc_func<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0, std::__1::allocator<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0>, void (facebook::jsi::Runtime&)>::operator()[abi:de190102](facebook::jsi::Runtime&) + 36
    frame #58: 0x000000010b080630 React`std::__1::__function::__func<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0, std::__1::allocator<facebook::react::RuntimeScheduler_Modern::scheduleEventLoop()::$_0>, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) + 36
    frame #59: 0x000000010b0fef0c React`std::__1::__function::__value_func<void (facebook::jsi::Runtime&)>::operator()[abi:de190102](facebook::jsi::Runtime&) const + 68
    frame #60: 0x000000010b0fd574 React`std::__1::function<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const + 32
    frame #61: 0x000000010b0fd1c4 React`_ZZZN8facebook5react13ReactInstanceC1ENSt3__110unique_ptrINS0_9JSRuntimeENS2_14default_deleteIS4_EEEENS2_10shared_ptrINS0_18MessageQueueThreadEEENS8_INS0_12TimerManagerEEENS2_8functionIFvRNS_3jsi7RuntimeERKNS0_14JsErrorHandler14ProcessedErrorEEEEPNS0_18jsinspector_modern10HostTargetEENK3$_0clINSD_IFvSG_EEEEEDaT_ENKUlvE_clEv + 164
    frame #62: 0x000000010b0fd114 React`_ZNSt3__18__invokeB8de190102IRZZN8facebook5react13ReactInstanceC1ENS_10unique_ptrINS2_9JSRuntimeENS_14default_deleteIS5_EEEENS_10shared_ptrINS2_18MessageQueueThreadEEENS9_INS2_12TimerManagerEEENS_8functionIFvRNS1_3jsi7RuntimeERKNS2_14JsErrorHandler14ProcessedErrorEEEEPNS2_18jsinspector_modern10HostTargetEENK3$_0clINSE_IFvSH_EEEEEDaT_EUlvE_JEEEDTclclsr3stdE7declvalISW_EEspclsr3stdE7declvalIT0_EEEEOSW_DpOSZ_ + 24
    frame #63: 0x000000010b0fd0cc React`_ZNSt3__128__invoke_void_return_wrapperIvLb1EE6__callB8de190102IJRZZN8facebook5react13ReactInstanceC1ENS_10unique_ptrINS4_9JSRuntimeENS_14default_deleteIS7_EEEENS_10shared_ptrINS4_18MessageQueueThreadEEENSB_INS4_12TimerManagerEEENS_8functionIFvRNS3_3jsi7RuntimeERKNS4_14JsErrorHandler14ProcessedErrorEEEEPNS4_18jsinspector_modern10HostTargetEENK3$_0clINSG_IFvSJ_EEEEEDaT_EUlvE_EEEvDpOT_ + 24
    frame #64: 0x000000010b0fd0a8 React`_ZNSt3__110__function12__alloc_funcIZZN8facebook5react13ReactInstanceC1ENS_10unique_ptrINS3_9JSRuntimeENS_14default_deleteIS6_EEEENS_10shared_ptrINS3_18MessageQueueThreadEEENSA_INS3_12TimerManagerEEENS_8functionIFvRNS2_3jsi7RuntimeERKNS3_14JsErrorHandler14ProcessedErrorEEEEPNS3_18jsinspector_modern10HostTargetEENK3$_0clINSF_IFvSI_EEEEEDaT_EUlvE_NS_9allocatorISY_EEFvvEEclB8de190102Ev + 28
    frame #65: 0x000000010b0fbde8 React`_ZNSt3__110__function6__funcIZZN8facebook5react13ReactInstanceC1ENS_10unique_ptrINS3_9JSRuntimeENS_14default_deleteIS6_EEEENS_10shared_ptrINS3_18MessageQueueThreadEEENSA_INS3_12TimerManagerEEENS_8functionIFvRNS2_3jsi7RuntimeERKNS3_14JsErrorHandler14ProcessedErrorEEEEPNS3_18jsinspector_modern10HostTargetEENK3$_0clINSF_IFvSI_EEEEEDaT_EUlvE_NS_9allocatorISY_EEFvvEEclEv + 28
    frame #66: 0x000000010a794904 React`std::__1::__function::__value_func<void ()>::operator()[abi:de190102]() const + 60
    frame #67: 0x000000010a793c64 React`std::__1::function<void ()>::operator()() const + 24
    frame #68: 0x000000010a7a37e0 React`facebook::react::tryAndReturnError(std::__1::function<void ()> const&) + 24
    frame #69: 0x000000010a793f4c React`facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) + 36
    frame #70: 0x000000010a7992c0 React`facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0::operator()() const + 80
    frame #71: 0x000000010a799264 React`decltype(std::declval<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0&>()()) std::__1::__invoke[abi:de190102]<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0&) + 24
    frame #72: 0x000000010a79921c React`void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:de190102]<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0&) + 24
    frame #73: 0x000000010a7991f8 React`std::__1::__function::__alloc_func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0, std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0>, void ()>::operator()[abi:de190102]() + 28
    frame #74: 0x000000010a797eb4 React`std::__1::__function::__func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0, std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_0>, void ()>::operator()() + 28
    frame #75: 0x000000010a794904 React`std::__1::__function::__value_func<void ()>::operator()[abi:de190102]() const + 60
    frame #76: 0x000000010a793c64 React`std::__1::function<void ()>::operator()() const + 24
    frame #77: 0x000000010a793c38 React`invocation function for block in facebook::react::RCTMessageThread::runAsync(std::__1::function<void ()>) + 48
    frame #78: 0x000000018e3d8694 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
    frame #79: 0x000000018e391aa8 CoreFoundation`__CFRunLoopDoBlocks + 356
    frame #80: 0x000000018e391444 CoreFoundation`__CFRunLoopRun + 1408
    frame #81: 0x000000018e39255c CoreFoundation`_CFRunLoopRunSpecificWithOptions + 344
    frame #82: 0x000000010b187850 React`+[RCTJSThreadManager runRunLoop] + 312
    frame #83: 0x000000018ea59cac Foundation`__NSThread__start__ + 732
    frame #84: 0x000000018e29a034 libsystem_pthread.dylib`_pthread_start + 136
  thread #20, name = 'hades'
    frame #0: 0x00000002450cf5f8 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018e297da4 libsystem_pthread.dylib`_pthread_cond_wait + 980
    frame #2: 0x00000001a5a61ae8 libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 32
    frame #3: 0x0000000103e25b9c hermesvm`hermes::vm::HadesGC::Executor::worker() + 108
    frame #4: 0x0000000103e25b04 hermesvm`void* std::__1::__thread_proxy[abi:nn190102]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, hermes::vm::HadesGC::Executor::Executor()::'lambda'()>>(void*) + 44
    frame #5: 0x000000018e29a034 libsystem_pthread.dylib`_pthread_start + 136
  thread #21, name = 'com.facebook.SocketRocket.NetworkThread'
    frame #0: 0x00000002450c9cd4 libsystem_kernel.dylib`mach_msg2_trap + 8
    frame #1: 0x00000002450cd308 libsystem_kernel.dylib`mach_msg2_internal + 76
    frame #2: 0x00000002450cd228 libsystem_kernel.dylib`mach_msg_overwrite + 424
    frame #3: 0x00000002450cd074 libsystem_kernel.dylib`mach_msg + 24
    frame #4: 0x000000018e3921d4 CoreFoundation`__CFRunLoopServiceMachPort + 136
    frame #5: 0x000000018e3911fc CoreFoundation`__CFRunLoopRun + 824
    frame #6: 0x000000018e39255c CoreFoundation`_CFRunLoopRunSpecificWithOptions + 344
    frame #7: 0x000000018e85b198 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
    frame #8: 0x00000001032dfc70 ReactNativeDependencies`-[SRRunLoopThread main] + 268
    frame #9: 0x000000018ea59cac Foundation`__NSThread__start__ + 732
    frame #10: 0x000000018e29a034 libsystem_pthread.dylib`_pthread_start + 136
  thread #22, name = 'com.apple.NSURLConnectionLoader'
    frame #0: 0x00000002450c9cd4 libsystem_kernel.dylib`mach_msg2_trap + 8
    frame #1: 0x00000002450cd308 libsystem_kernel.dylib`mach_msg2_internal + 76
    frame #2: 0x00000002450cd228 libsystem_kernel.dylib`mach_msg_overwrite + 424
    frame #3: 0x00000002450cd074 libsystem_kernel.dylib`mach_msg + 24
    frame #4: 0x000000018e3921d4 CoreFoundation`__CFRunLoopServiceMachPort + 136
    frame #5: 0x000000018e3911fc CoreFoundation`__CFRunLoopRun + 824
    frame #6: 0x000000018e39255c CoreFoundation`_CFRunLoopRunSpecificWithOptions + 344
    frame #7: 0x000000019a8a9114 CFNetwork`+[__CFN_CoreSchedulingSetRunnable _run:] + 392
    frame #8: 0x000000018ea59cac Foundation`__NSThread__start__ + 732
    frame #9: 0x000000018e29a034 libsystem_pthread.dylib`_pthread_start + 136
  thread #23
    frame #0: 0x000000018e296908 libsystem_pthread.dylib`start_wqthread
  thread #24
    frame #0: 0x000000018e296908 libsystem_pthread.dylib`start_wqthread
  thread #25
    frame #0: 0x000000018e296908 libsystem_pthread.dylib`start_wqthread
  thread #26
    frame #0: 0x000000018e296908 libsystem_pthread.dylib`start_wqthread
  thread #27
    frame #0: 0x0000000000000000

Additional context

Duplicates or relates to #4026

I'm not 100% sure if it's a bug or if one should actually not reuse outputs among camera sessions. From the docs I understood that it should be possible.

Our app has 4 different camera screens, each scanning a different category of barcodes and each with its own barcode processing logic. The screens stay in the stack. We tried to use the isActive prop but it was not working for us and that's why we unmount the <Camera> when navigating away from the screen while the hooks stay mounted.

As a workaround I refactored our code to have a Camera-wrapper-component which holds the <Camera> and our barcode processor hook so that the useBarcodeScannerOutput is unmounted in sync with the <Camera> so that every camera session has its own output and we are not getting into the situation that leads to the crash. This fixes the crash but makes the code a bit ugly.

I have a long Claude session in which we investigated this issue until we came to the root cause, the workaround, and the minimal reproducer. However I haven't added anything from it to this report.

Please let me know if there is anything else I can do to help.

Submission

  • The reproduction I linked is either (preferred) a PR against this repo that adds a failing harness test following the harness-tests README, or (fallback) a public repo that reproduces the bug on a fresh clone. I understand the issue will be closed without one.
  • I pasted logs as text (not screenshots).
  • I wrote this report in my own words. I did not paste AI-generated descriptions of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    馃悰 bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions