From a4a8695cec640e5cf12be36a0c871115fbce9c87 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 30 Oct 2023 13:38:32 -0700 Subject: [PATCH] Fix module create dead-lock when start-up (#41194) Summary: `UIManager` gets module deadlock when start-up randomly. I think we can move it to the secondary thread safely. ``` (lldb) bt all * thread https://github.com/facebook/react-native/issues/1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP frame #0: 0x000000010d66a5d6 libsystem_kernel.dylib`__psynch_cvwait + 10 frame https://github.com/facebook/react-native/issues/1: 0x000000010d5f476b libsystem_pthread.dylib`_pthread_cond_wait + 1211 frame https://github.com/facebook/react-native/issues/2: 0x000000010761dfe2 libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock&) + 18 frame https://github.com/facebook/react-native/issues/3: 0x00000001034a0a52 RNTester`-[RCTTurboModuleManager _provideObjCModule:moduleHolder:shouldPerfLog:](self=0x00007fafac10e990, _cmd="_provideObjCModule:moduleHolder:shouldPerfLog:", moduleName="AccessibilityManager", moduleHolder=0x0000600003c8cbd8, shouldPerfLog=YES) at RCTTurboModuleManager.mm:599:24 frame https://github.com/facebook/react-native/issues/4: 0x00000001034a0488 RNTester`-[RCTTurboModuleManager _provideObjCModule:](self=0x00007fafac10e990, _cmd="_provideObjCModule:", moduleName="AccessibilityManager") at RCTTurboModuleManager.mm:517:32 frame https://github.com/facebook/react-native/issues/5: 0x00000001034a2cfa RNTester`-[RCTTurboModuleManager moduleForName:warnOnLookupFailure:](self=0x00007fafac10e990, _cmd="moduleForName:warnOnLookupFailure:", moduleName="AccessibilityManager", warnOnLookupFailure=NO) at RCTTurboModuleManager.mm:976:32 frame https://github.com/facebook/react-native/issues/6: 0x00000001030ba6aa RNTester`-[RCTCxxBridge moduleForName:lazilyLoadIfNecessary:](self=0x00007fafac105ab0, _cmd="moduleForName:lazilyLoadIfNecessary:", moduleName="AccessibilityManager", lazilyLoad=YES) at RCTCxxBridge.mm:568:35 * frame https://github.com/facebook/react-native/issues/7: 0x000000010316fa38 RNTester`__26-[RCTUIManager setBridge:]_block_invoke(.block_descriptor=0x000060000055cb40) at RCTUIManager.m:188:55 frame https://github.com/facebook/react-native/issues/8: 0x00000001090cc747 libdispatch.dylib`_dispatch_call_block_and_release + 12 frame https://github.com/facebook/react-native/issues/9: 0x00000001090cd9f7 libdispatch.dylib`_dispatch_client_callout + 8 frame https://github.com/facebook/react-native/issues/10: 0x00000001090dd856 libdispatch.dylib`_dispatch_main_queue_drain + 1362 frame https://github.com/facebook/react-native/issues/11: 0x00000001090dd2f6 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 31 frame https://github.com/facebook/react-native/issues/12: 0x00000001088b4850 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 frame https://github.com/facebook/react-native/issues/13: 0x00000001088af18b CoreFoundation`__CFRunLoopRun + 2463 frame https://github.com/facebook/react-native/issues/14: 0x00000001088ae409 CoreFoundation`CFRunLoopRunSpecific + 557 frame https://github.com/facebook/react-native/issues/15: 0x0000000114ede187 GraphicsServices`GSEventRunModal + 137 frame https://github.com/facebook/react-native/issues/16: 0x0000000128be53a2 UIKitCore`-[UIApplication _run] + 972 frame https://github.com/facebook/react-native/issues/17: 0x0000000128be9e10 UIKitCore`UIApplicationMain + 123 frame https://github.com/facebook/react-native/issues/18: 0x0000000102fb7000 RNTester`main(argc=1, argv=0x00007ff7bcf4fce8) at main.m:15:12 frame https://github.com/facebook/react-native/issues/19: 0x00000001069023ee dyld_sim`start_sim + 10 frame https://github.com/facebook/react-native/issues/20: 0x000000010ea223a6 dyld`start + 1942 thread https://github.com/facebook/react-native/issues/6, name = 'com.apple.uikit.eventfetch-thread' frame #0: 0x000000010d667a2e libsystem_kernel.dylib`mach_msg2_trap + 10 frame https://github.com/facebook/react-native/issues/1: 0x000000010d675e4a libsystem_kernel.dylib`mach_msg2_internal + 84 frame https://github.com/facebook/react-native/issues/2: 0x000000010d66eb6e libsystem_kernel.dylib`mach_msg_overwrite + 653 frame https://github.com/facebook/react-native/issues/3: 0x000000010d667d1f libsystem_kernel.dylib`mach_msg + 19 frame https://github.com/facebook/react-native/issues/4: 0x00000001088b45bf CoreFoundation`__CFRunLoopServiceMachPort + 143 frame https://github.com/facebook/react-native/issues/5: 0x00000001088aed47 CoreFoundation`__CFRunLoopRun + 1371 frame https://github.com/facebook/react-native/issues/6: 0x00000001088ae409 CoreFoundation`CFRunLoopRunSpecific + 557 frame https://github.com/facebook/react-native/issues/7: 0x000000010a34ceee Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213 frame https://github.com/facebook/react-native/issues/8: 0x000000010a34d16c Foundation`-[NSRunLoop(NSRunLoop) runUntilDate:] + 72 frame https://github.com/facebook/react-native/issues/9: 0x0000000128cbd797 UIKitCore`-[UIEventFetcher threadMain] + 518 frame https://github.com/facebook/react-native/issues/10: 0x000000010a377699 Foundation`__NSThread__start__ + 1024 frame https://github.com/facebook/react-native/issues/11: 0x000000010d5f4202 libsystem_pthread.dylib`_pthread_start + 99 frame https://github.com/facebook/react-native/issues/12: 0x000000010d5efbab libsystem_pthread.dylib`thread_start + 15 thread https://github.com/facebook/react-native/issues/9, name = 'com.facebook.react.JavaScript' frame #0: 0x000000010d6691e2 libsystem_kernel.dylib`__ulock_wait + 10 frame https://github.com/facebook/react-native/issues/1: 0x00000001090ce319 libdispatch.dylib`_dlock_wait + 46 frame https://github.com/facebook/react-native/issues/2: 0x00000001090ce170 libdispatch.dylib`_dispatch_thread_event_wait_slow + 40 frame https://github.com/facebook/react-native/issues/3: 0x00000001090debb2 libdispatch.dylib`__DISPATCH_WAIT_FOR_QUEUE__ + 371 frame https://github.com/facebook/react-native/issues/4: 0x00000001090de5c9 libdispatch.dylib`_dispatch_sync_f_slow + 240 frame https://github.com/facebook/react-native/issues/5: 0x00000001031847cb RNTester`RCTUnsafeExecuteOnMainQueueSync(block=0x00000001034a0bf0) at RCTUtils.m:277:5 frame https://github.com/facebook/react-native/issues/6: 0x00000001034a0863 RNTester`-[RCTTurboModuleManager _provideObjCModule:moduleHolder:shouldPerfLog:](self=0x00007fafac10e990, _cmd="_provideObjCModule:moduleHolder:shouldPerfLog:", moduleName="AccessibilityManager", moduleHolder=0x0000600003c8cbd8, shouldPerfLog=YES) at RCTTurboModuleManager.mm:571:9 frame https://github.com/facebook/react-native/issues/7: 0x00000001034a0488 RNTester`-[RCTTurboModuleManager _provideObjCModule:](self=0x00007fafac10e990, _cmd="_provideObjCModule:", moduleName="AccessibilityManager") at RCTTurboModuleManager.mm:517:32 frame https://github.com/facebook/react-native/issues/8: 0x00000001034a2cfa RNTester`-[RCTTurboModuleManager moduleForName:warnOnLookupFailure:](self=0x00007fafac10e990, _cmd="moduleForName:warnOnLookupFailure:", moduleName="AccessibilityManager", warnOnLookupFailure=NO) at RCTTurboModuleManager.mm:976:32 frame https://github.com/facebook/react-native/issues/9: 0x00000001030ba6aa RNTester`-[RCTCxxBridge moduleForName:lazilyLoadIfNecessary:](self=0x00007fafac105ab0, _cmd="moduleForName:lazilyLoadIfNecessary:", moduleName="AccessibilityManager", lazilyLoad=YES) at RCTCxxBridge.mm:568:35 frame https://github.com/facebook/react-native/issues/10: 0x000000010366db7c RNTester`-[RCTBaseTextInputViewManager setBridge:](self=0x0000600000b19d60, _cmd="setBridge:", bridge=0x00007fafac105ab0) at RCTBaseTextInputViewManager.mm:104:53 frame https://github.com/facebook/react-native/issues/11: 0x000000010a2c1796 Foundation`-[NSObject(NSKeyValueCoding) setValue:forKey:] + 278 frame https://github.com/facebook/react-native/issues/12: 0x0000000103116f42 RNTester`-[RCTModuleData setBridgeForInstance](self=0x0000600003eb58c0, _cmd="setBridgeForInstance") at RCTModuleData.mm:256:7 frame https://github.com/facebook/react-native/issues/13: 0x0000000103116971 RNTester`-[RCTModuleData setUpInstanceAndBridge:](self=0x0000600003eb58c0, _cmd="setUpInstanceAndBridge:", requestId=10) at RCTModuleData.mm:210:7 frame https://github.com/facebook/react-native/issues/14: 0x0000000103118990 RNTester`-[RCTModuleData instance](self=0x0000600003eb58c0, _cmd="instance") at RCTModuleData.mm:395:7 frame https://github.com/facebook/react-native/issues/15: 0x00000001030ba8b6 RNTester`-[RCTCxxBridge moduleForName:lazilyLoadIfNecessary:](self=0x00007fafac105ab0, _cmd="moduleForName:lazilyLoadIfNecessary:", moduleName="BaseTextInputViewManager", lazilyLoad=YES) at RCTCxxBridge.mm:587:23 frame https://github.com/facebook/react-native/issues/16: 0x00000001030bad90 RNTester`-[RCTCxxBridge moduleForClass:](self=0x00007fafac105ab0, _cmd="moduleForClass:", moduleClass=RCTBaseTextInputViewManager) at RCTCxxBridge.mm:631:10 frame https://github.com/facebook/react-native/issues/17: 0x000000010309bd59 RNTester`-[RCTComponentData manager](self=0x0000600002fbd920, _cmd="manager") at RCTComponentData.m:67:16 frame https://github.com/facebook/react-native/issues/18: 0x00000001030a2831 RNTester`-[RCTComponentData viewConfig](self=0x0000600002fbd920, _cmd="viewConfig") at RCTComponentData.m:518:3 frame https://github.com/facebook/react-native/issues/19: 0x0000000103180216 RNTester`moduleConstantsForComponentData(directEvents=7 key/value pairs, bubblingEvents=2 key/value pairs, componentData=0x0000600002fbd920) at RCTUIManager.m:1568:99 frame https://github.com/facebook/react-native/issues/20: 0x00000001031800ea RNTester`__28-[RCTUIManager getConstants]_block_invoke(.block_descriptor=0x00007000042d35d0, name=@"RCTBaseTextInputView", componentData=0x0000600002fbd920, stop=NO) at RCTUIManager.m:1586:13 frame https://github.com/facebook/react-native/issues/21: 0x000000010889d4fd CoreFoundation`__NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 7 frame https://github.com/facebook/react-native/issues/22: 0x00000001089c9281 CoreFoundation`-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 249 frame https://github.com/facebook/react-native/issues/23: 0x000000010317feb7 RNTester`-[RCTUIManager getConstants](self=0x000060000206d0a0, _cmd="getConstants") at RCTUIManager.m:1582:3 frame https://github.com/facebook/react-native/issues/24: 0x000000010317fdb1 RNTester`-[RCTUIManager constantsToExport](self=0x000060000206d0a0, _cmd="constantsToExport") at RCTUIManager.m:1573:10 frame https://github.com/facebook/react-native/issues/25: 0x000000010311911b RNTester`-[RCTModuleData gatherConstantsAndSignalJSRequireEnding:](self=0x0000600003eb5500, _cmd="gatherConstantsAndSignalJSRequireEnding:", startMarkers=YES) at RCTModuleData.mm:462:28 frame https://github.com/facebook/react-native/issues/26: 0x00000001031193e9 RNTester`-[RCTModuleData exportedConstants](self=0x0000600003eb5500, _cmd="exportedConstants") at RCTModuleData.mm:477:3 frame https://github.com/facebook/react-native/issues/27: 0x0000000103125d09 RNTester`facebook::react::RCTNativeModule::getConstants(this=0x0000600000beac80) at RCTNativeModule.mm:68:42 frame https://github.com/facebook/react-native/issues/28: 0x000000010370a0f2 RNTester`facebook::react::ModuleRegistry::getConfig(this=0x0000600003e913a0, name="UIManager") at ModuleRegistry.cpp:154:30 frame https://github.com/facebook/react-native/issues/29: 0x0000000103797b6e RNTester`facebook::react::JSINativeModules::createModule(this=0x0000600002f8cf78, rt=0x0000600002f8d278, name="UIManager") at JSINativeModules.cpp:81:35 frame https://github.com/facebook/react-native/issues/30: 0x000000010379778c RNTester`facebook::react::JSINativeModules::getModule(this=0x0000600002f8cf78, rt=0x0000600002f8d278, name=0x00007000042d4138) at JSINativeModules.cpp:46:17 frame https://github.com/facebook/react-native/issues/31: 0x000000010378814a RNTester`facebook::react::JSIExecutor::NativeModuleProxy::get(this=0x000060000057ac88, rt=0x0000600002f8d278, name=0x00007000042d4138) at JSIExecutor.cpp:44:27 frame https://github.com/facebook/react-native/issues/32: 0x00000001037448d6 RNTester`facebook::jsi::DecoratedHostObject::get(this=0x0000600001e3e118, (null)=0x0000600003cb8630, name=0x00007000042d4138) at decorator.h:70:22 frame https://github.com/facebook/react-native/issues/33: 0x0000000109667ff7 hermes`facebook::hermes::HermesRuntimeImpl::JsiProxy::get(this=0x0000600000ba4d20, id=(id_ = 4435)) at hermes.cpp:698:20 [opt] frame https://github.com/facebook/react-native/issues/34: 0x00000001096e7436 hermes`hermes::vm::JSObject::getComputedWithReceiver_RJS(hermes::vm::Handle, hermes::vm::Runtime&, hermes::vm::Handle, hermes::vm::Handle) [inlined] hermes::vm::HostObject::get(this=, name=) at HostModel.h:112:24 [opt] frame https://github.com/facebook/react-native/issues/35: 0x00000001096e742c hermes`hermes::vm::JSObject::getComputedWithReceiver_RJS(selfHandle=, runtime=0x00007fafae026000, nameValHandle=, receiver=Handle @ 0x00007000042d4190) at JSObject.cpp:1182:55 [opt] frame https://github.com/facebook/react-native/issues/36: 0x00000001096cc141 hermes`hermes::vm::CallResult hermes::vm::Interpreter::interpretFunction(hermes::vm::Runtime&, hermes::vm::InterpreterState&) [inlined] hermes::vm::JSObject::getComputed_RJS(selfHandle=, runtime=0x00007fafae026000, nameValHandle=) at JSObject.h:1940:10 [opt] frame https://github.com/facebook/react-native/issues/37: 0x00000001096cc12f hermes`hermes::vm::CallResult hermes::vm::Interpreter::interpretFunction(runtime=0x00007fafae026000, state=0x00007000042d4470) at Interpreter.cpp:2481:11 [opt] frame https://github.com/facebook/react-native/issues/38: 0x00000001096c84bc hermes`hermes::vm::Runtime::interpretFunctionImpl(this=0x00007fafae026000, newCodeBlock=0x0000600003068000) at Interpreter.cpp:825:12 [opt] frame https://github.com/facebook/react-native/issues/39: 0x000000010970fbc8 hermes`hermes::vm::Runtime::runBytecode(this=0x00007fafae026000, bytecode=, flags=, sourceURL=(Data = "http://localhost:8081/js/RNTesterApp.ios.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.meta.RNTester.localDevelopment", Length = 188), environment=Handle @ 0x00007000042d44d0, thisArg=Handle @ 0x00007000042d4630) at Runtime.cpp:1079:11 [opt] frame https://github.com/facebook/react-native/issues/40: 0x000000010965ac1d hermes`facebook::hermes::HermesRuntimeImpl::evaluatePreparedJavaScript(std::__1::shared_ptr const&) [inlined] hermes::vm::Runtime::runBytecode(this=0x00007fafae026000, bytecode=nullptr, runtimeModuleFlags=RuntimeModuleFlags @ rbx, sourceURL=(Data = 0x0000000000000000, Length = 188), environment=) at Runtime.h:277:12 [opt] frame https://github.com/facebook/react-native/issues/41: 0x000000010965abe7 hermes`facebook::hermes::HermesRuntimeImpl::evaluatePreparedJavaScript(this=0x0000600003cb8630, js=std::__1::shared_ptr::element_type @ 0x00006000028d7038 strong=1 weak=1) at hermes.cpp:1494:23 [opt] frame https://github.com/facebook/react-native/issues/42: 0x000000010965aaa0 hermes`facebook::hermes::HermesRuntime::evaluateJavaScriptWithSourceMap(this=0x0000600003cb8630, buffer=std::__1::shared_ptr::element_type @ 0x00006000009b4590 strong=2 weak=1, sourceMapBuf=nullptr, sourceURL=) at hermes.cpp:1361:22 [opt] frame https://github.com/facebook/react-native/issues/43: 0x000000010965bdef hermes`facebook::hermes::HermesRuntimeImpl::evaluateJavaScript(this=, buffer=, sourceURL=) at hermes.cpp:1506:10 [opt] frame https://github.com/facebook/react-native/issues/44: 0x0000000103742ef1 RNTester`facebook::jsi::RuntimeDecorator::evaluateJavaScript(this=0x0000600002f8d278, buffer=std::__1::shared_ptr::element_type @ 0x00006000009b4590 strong=2 weak=1, sourceURL="http://localhost:8081/js/RNTesterApp.ios.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.meta.RNTester.localDevelopment") at decorator.h:118:20 frame https://github.com/facebook/react-native/issues/45: 0x000000010374086d RNTester`facebook::jsi::WithRuntimeDecorator::evaluateJavaScript(this=0x0000600002f8d278, buffer=std::__1::shared_ptr::element_type @ 0x00006000009b4590 strong=2 weak=1, sourceURL="http://localhost:8081/js/RNTesterApp.ios.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.meta.RNTester.localDevelopment") at decorator.h:530:16 frame https://github.com/facebook/react-native/issues/46: 0x0000000103782c60 RNTester`facebook::react::JSIExecutor::loadBundle(this=0x00007fafabb07990, script=nullptr, sourceURL="http://localhost:8081/js/RNTesterApp.ios.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.meta.RNTester.localDevelopment") at JSIExecutor.cpp:160:13 frame https://github.com/facebook/react-native/issues/47: 0x0000000103718719 RNTester`facebook::react::NativeToJsBridge::loadBundle(std::__1::unique_ptr>, std::__1::unique_ptr>, std::__1::basic_string, std::__1::allocator>)::$_1::operator()(this=0x0000600001e81fc8, executor=0x00007fafabb07990) at NativeToJsBridge.cpp:144:21 frame https://github.com/facebook/react-native/issues/48: 0x0000000103718600 RNTester`decltype(std::declval>, std::__1::unique_ptr>, std::__1::basic_string, std::__1::allocator>)::$_1&>()(std::declval())) std::__1::__invoke[abi:v160006]>, std::__1::unique_ptr>, std::__1::basic_string, std::__1::allocator>)::$_1&, facebook::react::JSExecutor*>(__f=0x0000600001e81fc8, __args=0x00007000042d4aa0) at invoke.h:394:23 frame https://github.com/facebook/react-native/issues/49: 0x00000001037185ad RNTester`void std::__1::__invoke_void_return_wrapper::__call>, std::__1::unique_ptr>, std::__1::basic_string, std::__1::allocator>)::$_1&, facebook::react::JSExecutor*>(__args=0x0000600001e81fc8, __args=0x00007000042d4aa0) at invoke.h:487:9 frame https://github.com/facebook/react-native/issues/50: 0x0000000103718585 RNTester`std::__1::__function::__alloc_func>, std::__1::unique_ptr>, std::__1::basic_string, std::__1::allocator>)::$_1, std::__1::allocator>, std::__1::unique_ptr>, std::__1::basic_string, std::__1::allocator>)::$_1>, void (facebook::react::JSExecutor*)>::operator()[abi:v160006](this=0x0000600001e81fc8, __arg=0x00007000042d4aa0) at function.h:185:16 frame https://github.com/facebook/react-native/issues/51: 0x0000000103717311 RNTester`std::__1::__function::__func>, std::__1::unique_ptr>, std::__1::basic_string, std::__1::allocator>)::$_1, std::__1::allocator>, std::__1::unique_ptr>, std::__1::basic_string, std::__1::allocator>)::$_1>, void (facebook::react::JSExecutor*)>::operator()(this=0x0000600001e81fc0, __arg=0x00007000042d4aa0) at function.h:356:12 frame https://github.com/facebook/react-native/issues/52: 0x0000000103723f2a RNTester`std::__1::__function::__value_func::operator()[abi:v160006](this=0x0000600002fad4d0, __args=0x00007000042d4aa0) const at function.h:510:16 frame https://github.com/facebook/react-native/issues/53: 0x0000000103723ebd RNTester`std::__1::function::operator()(this=0x0000600002fad4d0, __arg=0x00007fafabb07990) const at function.h:1156:12 frame https://github.com/facebook/react-native/issues/54: 0x0000000103723e97 RNTester`facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function&&)::$_8::operator()(this=0x0000600002fad4b0) const at NativeToJsBridge.cpp:308:9 frame https://github.com/facebook/react-native/issues/55: 0x0000000103723e35 RNTester`decltype(std::declval&&)::$_8&>()()) std::__1::__invoke[abi:v160006]&&)::$_8&>(__f=0x0000600002fad4b0) at invoke.h:394:23 frame https://github.com/facebook/react-native/issues/56: 0x0000000103723df5 RNTester`void std::__1::__invoke_void_return_wrapper::__call&&)::$_8&>(__args=0x0000600002fad4b0) at invoke.h:487:9 frame https://github.com/facebook/react-native/issues/57: 0x0000000103723dcd RNTester`std::__1::__function::__alloc_func&&)::$_8, std::__1::allocator&&)::$_8>, void ()>::operator()[abi:v160006](this=0x0000600002fad4b0) at function.h:185:16 frame https://github.com/facebook/react-native/issues/58: 0x0000000103722b89 RNTester`std::__1::__function::__func&&)::$_8, std::__1::allocator&&)::$_8>, void ()>::operator()(this=0x0000600002fad4a0) at function.h:356:12 frame https://github.com/facebook/react-native/issues/59: 0x00000001030cdd72 RNTester`std::__1::__function::__value_func::operator()[abi:v160006](this=0x00006000028f85c0) const at function.h:510:16 frame https://github.com/facebook/react-native/issues/60: 0x00000001030cdd35 RNTester`std::__1::function::operator()(this= Lambda in File NativeToJsBridge.cpp at Line 298) const at function.h:1156:12 frame https://github.com/facebook/react-native/issues/61: 0x00000001030e1145 RNTester`facebook::react::tryAndReturnError(func= Lambda in File NativeToJsBridge.cpp at Line 298) at RCTCxxUtils.mm:73:7 frame https://github.com/facebook/react-native/issues/62: 0x000000010310a5c1 RNTester`facebook::react::RCTMessageThread::tryFunc(this=0x00006000028f0018, func= Lambda in File NativeToJsBridge.cpp at Line 298) at RCTMessageThread.mm:68:20 frame https://github.com/facebook/react-native/issues/63: 0x000000010310e823 RNTester`facebook::react::RCTMessageThread::runOnQueue(std::__1::function&&)::$_1::operator()(this=0x0000600000538d88) const at RCTMessageThread.mm:81:19 frame https://github.com/facebook/react-native/issues/64: 0x000000010310e7c5 RNTester`decltype(std::declval&&)::$_1&>()()) std::__1::__invoke[abi:v160006]&&)::$_1&>(__f=0x0000600000538d88) at invoke.h:394:23 frame https://github.com/facebook/react-native/issues/65: 0x000000010310e785 RNTester`void std::__1::__invoke_void_return_wrapper::__call&&)::$_1&>(__args=0x0000600000538d88) at invoke.h:487:9 frame https://github.com/facebook/react-native/issues/66: 0x000000010310e75d RNTester`std::__1::__function::__alloc_func&&)::$_1, std::__1::allocator&&)::$_1>, void ()>::operator()[abi:v160006](this=0x0000600000538d88) at function.h:185:16 frame https://github.com/facebook/react-native/issues/67: 0x000000010310d709 RNTester`std::__1::__function::__func&&)::$_1, std::__1::allocator&&)::$_1>, void ()>::operator()(this=0x0000600000538d80) at function.h:356:12 frame https://github.com/facebook/react-native/issues/68: 0x00000001030cdd72 RNTester`std::__1::__function::__value_func::operator()[abi:v160006](this=0x00006000028fa690) const at function.h:510:16 frame https://github.com/facebook/react-native/issues/69: 0x00000001030cdd35 RNTester`std::__1::function::operator()(this= Lambda in File RCTMessageThread.mm at Line 79) const at function.h:1156:12 frame https://github.com/facebook/react-native/issues/70: 0x000000010310a39a RNTester`invocation function for block in facebook::react::RCTMessageThread::runAsync(.block_descriptor=0x00006000028fa670) at RCTMessageThread.mm:44:7 frame https://github.com/facebook/react-native/issues/71: 0x00000001088b4b06 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 frame https://github.com/facebook/react-native/issues/72: 0x00000001088b42b9 CoreFoundation`__CFRunLoopDoBlocks + 391 frame https://github.com/facebook/react-native/issues/73: 0x00000001088af076 CoreFoundation`__CFRunLoopRun + 2186 frame https://github.com/facebook/react-native/issues/74: 0x00000001088ae409 CoreFoundation`CFRunLoopRunSpecific + 557 frame https://github.com/facebook/react-native/issues/75: 0x00000001030b6ec5 RNTester`+[RCTCxxBridge runRunLoop](self=RCTCxxBridge, _cmd="runRunLoop") at RCTCxxBridge.mm:332:12 frame https://github.com/facebook/react-native/issues/76: 0x000000010a377699 Foundation`__NSThread__start__ + 1024 frame https://github.com/facebook/react-native/issues/77: 0x000000010d5f4202 libsystem_pthread.dylib`_pthread_start + 99 frame https://github.com/facebook/react-native/issues/78: 0x000000010d5efbab libsystem_pthread.dylib`thread_start + 15 thread https://github.com/facebook/react-native/issues/10, name = 'hades' frame #0: 0x000000010d66a5d6 libsystem_kernel.dylib`__psynch_cvwait + 10 frame https://github.com/facebook/react-native/issues/1: 0x000000010d5f476b libsystem_pthread.dylib`_pthread_cond_wait + 1211 frame https://github.com/facebook/react-native/issues/2: 0x000000010761dfe2 libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock&) + 18 frame https://github.com/facebook/react-native/issues/3: 0x00000001097aee78 hermes`hermes::vm::HadesGC::Executor::worker() [inlined] void std::__1::condition_variable::wait(this=0x0000600003cb8300, __lk=0x0000700004358f20, __pred=(unnamed class) @ rbx) at __mutex_base:400:9 [opt] frame https://github.com/facebook/react-native/issues/4: 0x00000001097aee5a hermes`hermes::vm::HadesGC::Executor::worker(this=0x0000600003cb82c0) at HadesGC.cpp:1084:11 [opt] frame https://github.com/facebook/react-native/issues/5: 0x00000001097aedba hermes`void* std::__1::__thread_proxy[abi:v160006]>, hermes::vm::HadesGC::Executor::Executor()::'lambda'()>>(void*) [inlined] hermes::vm::HadesGC::Executor::Executor(this=0x00006000009a8ba8)::'lambda'()::operator()() const at HadesGC.cpp:1051:33 [opt] frame https://github.com/facebook/react-native/issues/6: 0x00000001097aedb5 hermes`void* std::__1::__thread_proxy[abi:v160006]>, hermes::vm::HadesGC::Executor::Executor()::'lambda'()>>(void*) [inlined] decltype(std::declval()()) std::__1::__invoke[abi:v160006](__f=0x00006000009a8ba8) at invoke.h:394:23 [opt] frame https://github.com/facebook/react-native/issues/7: 0x00000001097aedb5 hermes`void* std::__1::__thread_proxy[abi:v160006]>, hermes::vm::HadesGC::Executor::Executor()::'lambda'()>>(void*) [inlined] void std::__1::__thread_execute[abi:v160006]>, hermes::vm::HadesGC::Executor::Executor()::'lambda'()>(__t=size=2, (null)=) at thread:288:5 [opt] frame https://github.com/facebook/react-native/issues/8: 0x00000001097aedb5 hermes`void* std::__1::__thread_proxy[abi:v160006]>, hermes::vm::HadesGC::Executor::Executor()::'lambda'()>>(__vp=0x00006000009a8ba0) at thread:299:5 [opt] frame https://github.com/facebook/react-native/issues/9: 0x000000010d5f4202 libsystem_pthread.dylib`_pthread_start + 99 frame https://github.com/facebook/react-native/issues/10: 0x000000010d5efbab libsystem_pthread.dylib`thread_start + 15 thread https://github.com/facebook/react-native/issues/11, name = 'com.apple.CFStream.LegacyThread' frame #0: 0x000000010d667a2e libsystem_kernel.dylib`mach_msg2_trap + 10 frame https://github.com/facebook/react-native/issues/1: 0x000000010d675e4a libsystem_kernel.dylib`mach_msg2_internal + 84 frame https://github.com/facebook/react-native/issues/2: 0x000000010d66eb6e libsystem_kernel.dylib`mach_msg_overwrite + 653 frame https://github.com/facebook/react-native/issues/3: 0x000000010d667d1f libsystem_kernel.dylib`mach_msg + 19 frame https://github.com/facebook/react-native/issues/4: 0x00000001088b45bf CoreFoundation`__CFRunLoopServiceMachPort + 143 frame https://github.com/facebook/react-native/issues/5: 0x00000001088aed47 CoreFoundation`__CFRunLoopRun + 1371 frame https://github.com/facebook/react-native/issues/6: 0x00000001088ae409 CoreFoundation`CFRunLoopRunSpecific + 557 frame https://github.com/facebook/react-native/issues/7: 0x00000001088d1e34 CoreFoundation`_legacyStreamRunLoop_workThread + 251 frame https://github.com/facebook/react-native/issues/8: 0x000000010d5f4202 libsystem_pthread.dylib`_pthread_start + 99 frame https://github.com/facebook/react-native/issues/9: 0x000000010d5efbab libsystem_pthread.dylib`thread_start + 15 thread https://github.com/facebook/react-native/issues/12, name = 'com.facebook.SocketRocket.NetworkThread' frame #0: 0x000000010d667a2e libsystem_kernel.dylib`mach_msg2_trap + 10 frame https://github.com/facebook/react-native/issues/1: 0x000000010d675e4a libsystem_kernel.dylib`mach_msg2_internal + 84 frame https://github.com/facebook/react-native/issues/2: 0x000000010d66eb6e libsystem_kernel.dylib`mach_msg_overwrite + 653 frame https://github.com/facebook/react-native/issues/3: 0x000000010d667d1f libsystem_kernel.dylib`mach_msg + 19 frame https://github.com/facebook/react-native/issues/4: 0x00000001088b45bf CoreFoundation`__CFRunLoopServiceMachPort + 143 frame https://github.com/facebook/react-native/issues/5: 0x00000001088aed47 CoreFoundation`__CFRunLoopRun + 1371 frame https://github.com/facebook/react-native/issues/6: 0x00000001088ae409 CoreFoundation`CFRunLoopRunSpecific + 557 frame https://github.com/facebook/react-native/issues/7: 0x000000010a34ceee Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213 frame https://github.com/facebook/react-native/issues/8: 0x000000010381a49b RNTester`-[SRRunLoopThread main](self=0x00006000028e80f0, _cmd="main") at SRRunLoopThread.m:71:16 frame https://github.com/facebook/react-native/issues/9: 0x000000010a377699 Foundation`__NSThread__start__ + 1024 frame https://github.com/facebook/react-native/issues/10: 0x000000010d5f4202 libsystem_pthread.dylib`_pthread_start + 99 frame https://github.com/facebook/react-native/issues/11: 0x000000010d5efbab libsystem_pthread.dylib`thread_start + 15 thread https://github.com/facebook/react-native/issues/13 frame #0: 0x000000010d5efb88 libsystem_pthread.dylib`start_wqthread thread https://github.com/facebook/react-native/issues/14, name = 'com.apple.NSURLConnectionLoader' frame #0: 0x000000010d667a2e libsystem_kernel.dylib`mach_msg2_trap + 10 frame https://github.com/facebook/react-native/issues/1: 0x000000010d675e4a libsystem_kernel.dylib`mach_msg2_internal + 84 frame https://github.com/facebook/react-native/issues/2: 0x000000010d66eb6e libsystem_kernel.dylib`mach_msg_overwrite + 653 frame https://github.com/facebook/react-native/issues/3: 0x000000010d667d1f libsystem_kernel.dylib`mach_msg + 19 frame https://github.com/facebook/react-native/issues/4: 0x00000001088b45bf CoreFoundation`__CFRunLoopServiceMachPort + 143 frame https://github.com/facebook/react-native/issues/5: 0x00000001088aed47 CoreFoundation`__CFRunLoopRun + 1371 frame https://github.com/facebook/react-native/issues/6: 0x00000001088ae409 CoreFoundation`CFRunLoopRunSpecific + 557 frame https://github.com/facebook/react-native/issues/7: 0x00000001093cf78b CFNetwork`___lldb_unnamed_symbol13826 + 444 frame https://github.com/facebook/react-native/issues/8: 0x000000010a377699 Foundation`__NSThread__start__ + 1024 frame https://github.com/facebook/react-native/issues/9: 0x000000010d5f4202 libsystem_pthread.dylib`_pthread_start + 99 frame https://github.com/facebook/react-native/issues/10: 0x000000010d5efbab libsystem_pthread.dylib`thread_start + 15 thread https://github.com/facebook/react-native/issues/15, name = 'com.apple.CFSocket.private' frame #0: 0x000000010d670922 libsystem_kernel.dylib`__select + 10 frame https://github.com/facebook/react-native/issues/1: 0x00000001088c2dcf CoreFoundation`__CFSocketManager + 643 frame https://github.com/facebook/react-native/issues/2: 0x000000010d5f4202 libsystem_pthread.dylib`_pthread_start + 99 frame https://github.com/facebook/react-native/issues/3: 0x000000010d5efbab libsystem_pthread.dylib`thread_start + 15 ``` ## Changelog: [IOS] [FIXED] - Fix module create dead-lock when start-up Pull Request resolved: https://github.com/facebook/react-native/pull/41194 Test Plan: Null. Reviewed By: javache Differential Revision: D50800290 Pulled By: sammy-SC fbshipit-source-id: b60b8e0681cbec7b7aa8812188c9f7ea5f03966b --- packages/react-native/React/Modules/RCTUIManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/React/Modules/RCTUIManager.m b/packages/react-native/React/Modules/RCTUIManager.m index c6b73cc5bbbdf0..4167fb122841f5 100644 --- a/packages/react-native/React/Modules/RCTUIManager.m +++ b/packages/react-native/React/Modules/RCTUIManager.m @@ -181,7 +181,7 @@ - (void)setBridge:(RCTBridge *)bridge } // This dispatch_async avoids a deadlock while configuring native modules - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNewContentSizeMultiplier) name:@"RCTAccessibilityManagerDidUpdateMultiplierNotification"