Skip to content

Commit 98bc2c7

Browse files
philIipfacebook-github-bot
authored andcommitted
put PR#41194 behind gating (facebook#41469)
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
1 parent 1eff870 commit 98bc2c7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/react-native/React/Modules/RCTUIManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
RCT_EXTERN NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification;
2222

23+
RCT_EXTERN void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled);
24+
2325
@class RCTLayoutAnimationGroup;
2426
@class RCTUIManagerObserverCoordinator;
2527

packages/react-native/React/Modules/RCTUIManager.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ static void RCTTraverseViewNodes(id<RCTComponent> view, void (^block)(id<RCTComp
6161
NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification =
6262
@"RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification";
6363

64+
BOOL kDispatchAccessibilityManagerInitOntoMain = NO;
65+
void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled)
66+
{
67+
kDispatchAccessibilityManagerInitOntoMain = enabled;
68+
}
69+
6470
@implementation RCTUIManager {
6571
// Root views are only mutated on the shadow queue
6672
NSMutableSet<NSNumber *> *_rootViewTags;
@@ -181,7 +187,10 @@ - (void)setBridge:(RCTBridge *)bridge
181187
}
182188

183189
// This dispatch_async avoids a deadlock while configuring native modules
184-
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
190+
dispatch_queue_t accessibilityManagerInitQueue = kDispatchAccessibilityManagerInitOntoMain
191+
? dispatch_get_main_queue()
192+
: dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0);
193+
dispatch_async(accessibilityManagerInitQueue, ^{
185194
[[NSNotificationCenter defaultCenter] addObserver:self
186195
selector:@selector(didReceiveNewContentSizeMultiplier)
187196
name:@"RCTAccessibilityManagerDidUpdateMultiplierNotification"

0 commit comments

Comments
 (0)