Skip to content

Commit

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

Changelog: [Internal]

PR#41194 (#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 13, 2023
1 parent 1eff870 commit 98bc2c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/react-native/React/Modules/RCTUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*/
RCT_EXTERN NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification;

RCT_EXTERN void RCTUIManagerSetDispatchAccessibilityManagerInitOntoMain(BOOL enabled);

@class RCTLayoutAnimationGroup;
@class RCTUIManagerObserverCoordinator;

Expand Down
11 changes: 10 additions & 1 deletion packages/react-native/React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ static void RCTTraverseViewNodes(id<RCTComponent> view, void (^block)(id<RCTComp
NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification =
@"RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification";

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

@implementation RCTUIManager {
// Root views are only mutated on the shadow queue
NSMutableSet<NSNumber *> *_rootViewTags;
Expand Down Expand Up @@ -181,7 +187,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 = kDispatchAccessibilityManagerInitOntoMain
? 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 98bc2c7

Please sign in to comment.