From e1d22857916a2b9458368f400755b720f6ea8ed3 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 1 May 2025 04:48:55 -0700 Subject: [PATCH] Do not access to main bundle when running in prod (#51043) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51043 The call to the mainBundle to read the `RCTLegacyWarningsEnabled` key can sometime deadlock in prod. However, these are development logs that we don't want to run in Prod. This change should disable the logs in prod, skipping the access to the `mainBundle`, and avoid the deadlock completely. ## Changelog: [Internal] - Fix deadlock at startup to read `RCTLegacyWarningsEnabled` Reviewed By: philIip, javache Differential Revision: D73987454 fbshipit-source-id: 014410266733fdfa1e7b29d41fab5f7112b1ddb4 --- packages/react-native/React/Base/RCTUtils.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/React/Base/RCTUtils.mm b/packages/react-native/React/Base/RCTUtils.mm index 4501fb3533b..77671fcabf9 100644 --- a/packages/react-native/React/Base/RCTUtils.mm +++ b/packages/react-native/React/Base/RCTUtils.mm @@ -49,9 +49,13 @@ void RCTSetNewArchEnabled(BOOL enabled) BOOL RCTAreLegacyLogsEnabled(void) { +#if RCT_DEBUG NSNumber *rctNewArchEnabled = (NSNumber *)[[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTLegacyWarningsEnabled"]; return rctNewArchEnabled.boolValue; +#else + return NO; +#endif } static NSString *__nullable _RCTJSONStringifyNoRetry(id __nullable jsonObject, NSError **error)