Skip to content

Commit

Permalink
put PR#41194 behind gating (facebook#41469)
Browse files Browse the repository at this point in the history
Summary:

Changelog: [Internal]

PR#41194 (facebook#41194) introduces a new callsite to `RCTUnsafeExecuteOnMainQueueSync` in the module init path, which increases risk for deadlock. let's gate it

Differential Revision: D51274859
  • Loading branch information
philIip authored and facebook-github-bot committed Nov 14, 2023
1 parent ad0f064 commit d7a664e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/react-native/React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ void RCTEnableTurboModuleSyncVoidMethods(BOOL enabled);
BOOL RCTTurboModuleSharedQueueEnabled(void);
void RCTEnableTurboModuleSharedQueue(BOOL enabled);

BOOL RCTUIManagerDispatchAccessibilityManagerInitOntoMain(void);
void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled);

typedef enum {
kRCTBridgeProxyLoggingLevelNone,
kRCTBridgeProxyLoggingLevelWarning,
Expand Down
11 changes: 11 additions & 0 deletions packages/react-native/React/Base/RCTBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ void RCTEnableTurboModuleSharedQueue(BOOL enabled)
gTurboModuleEnableSharedQueue = enabled;
}

BOOL kDispatchAccessibilityManagerInitOntoMain = NO;
BOOL RCTUIManagerDispatchAccessibilityManagerInitOntoMain(void)
{
return kDispatchAccessibilityManagerInitOntoMain;
}

void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled)
{
kDispatchAccessibilityManagerInitOntoMain = enabled;
}

@interface RCTBridge () <RCTReloadListener>
@end

Expand Down
5 changes: 4 additions & 1 deletion packages/react-native/React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ - (void)setBridge:(RCTBridge *)bridge
}

// This dispatch_async avoids a deadlock while configuring native modules
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
dispatch_queue_t accessibilityManagerInitQueue = RCTUIManagerDispatchAccessibilityManagerInitOntoMain()
? dispatch_get_main_queue()
: dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0);
dispatch_async(accessibilityManagerInitQueue, ^{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveNewContentSizeMultiplier)
name:@"RCTAccessibilityManagerDidUpdateMultiplierNotification"
Expand Down

0 comments on commit d7a664e

Please sign in to comment.