Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/react-native/React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ - (void)setBridge:(RCTBridge *)bridge
}
}

// Preload the a11yManager as the RCTUIManager needs it to listen for notification
// By eagerly preloading it in the setBridge method, we make sure that the manager is
// properly initialized in the Main Thread and that we do not incur in any race condition
// or concurrency problem.
id<RCTBridgeModule> a11yManager = [bridge moduleForName:@"AccessibilityManager" lazilyLoadIfNecessary:YES];

// This dispatch_async avoids a deadlock while configuring native modules
dispatch_queue_t accessibilityManagerInitQueue = RCTUIManagerDispatchAccessibilityManagerInitOntoMain()
? dispatch_get_main_queue()
Expand All @@ -188,8 +194,7 @@ - (void)setBridge:(RCTBridge *)bridge
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveNewContentSizeMultiplier)
name:@"RCTAccessibilityManagerDidUpdateMultiplierNotification"
object:[self->_bridge moduleForName:@"AccessibilityManager"
lazilyLoadIfNecessary:YES]];
object:a11yManager];
});
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(namedOrientationDidChange)
Expand Down