From 9f3b6082dac8a65e68d6abb74b09ab6abfc28704 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 14 Jul 2020 14:27:53 -0700 Subject: [PATCH] Only show deadlock warning when TM eager init is on Summary: During setup, TurboModules may synchronously dispatch to the main queue, if they require main queue setup. This is dangerous because it could cause the app to deadlock during TurboModule require. This is why D21654637 (https://github.com/facebook/react-native/commit/e206e34175c091a753c0e733abeda41b662241d4) added a warning aginst this. However, this diff had a mistake. We only want to display the warning if TurboModule eager initialization is enabled, because then, we can eagerly initialize the TurboModules before the bridge starts to avoid the problem. D21654637 (https://github.com/facebook/react-native/commit/e206e34175c091a753c0e733abeda41b662241d4) instead showed the warning if TurboModule eager init **wasn't** enabled. This isn't useful, because there's no way to avoid the problem with TurboModu eager initialization off. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D22529780 fbshipit-source-id: 15238483758b66b1a6addcad948203c64dca96ad --- .../turbomodule/core/platform/ios/RCTTurboModuleManager.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm index 0656a085a16..f93dfa4f1ae 100644 --- a/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm @@ -397,11 +397,11 @@ static Class getFallbackClassFromName(const char *name) if ([self _requiresMainQueueSetup:moduleClass]) { /** - * When TurboModule eager initialization is disabled, we expect TurboModules requiring main queue setup to be - * required on background threads. + * When TurboModule eager initialization is enabled, there shouldn't be any TurboModule initializations on the + * main queue. * TODO(T69449176) Roll out TurboModule eager initialization, and remove this check. */ - if (!RCTIsMainQueue() && !RCTTurboModuleEagerInitEnabled()) { + if (RCTTurboModuleEagerInitEnabled() && !RCTIsMainQueue()) { RCTLogWarn( @"TurboModule \"%@\" requires synchronous dispatch onto the main queue to be initialized. This may lead to deadlock.", moduleClass);