diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index d065b1b7943d..0cdbb3183f5b 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -379,13 +379,10 @@ - (void)_start */ NSArray *modulesRequiringMainQueueSetup = [_delegate unstableModulesRequiringMainQueueSetup]; - std::shared_ptr mutex = std::make_shared(); - std::shared_ptr cv = std::make_shared(); - std::shared_ptr isReady = std::make_shared(false); + dispatch_semaphore_t moduleSetupComplete = dispatch_semaphore_create(0); _waitUntilModuleSetupComplete = ^{ - std::unique_lock lock(*mutex); - cv->wait(lock, [isReady] { return *isReady; }); + dispatch_semaphore_wait(moduleSetupComplete, DISPATCH_TIME_FOREVER); }; // TODO(T218039767): Integrate perf logging into main queue module init @@ -398,9 +395,7 @@ - (void)_start RCTScreenScale(); RCTSwitchSize(); - std::lock_guard lock(*mutex); - *isReady = true; - cv->notify_all(); + dispatch_semaphore_signal(moduleSetupComplete); }); }