diff --git a/packages/react-native/React/Modules/RCTUIManager.m b/packages/react-native/React/Modules/RCTUIManager.m index fca5ee7aa90072..1d85520d0a4a78 100644 --- a/packages/react-native/React/Modules/RCTUIManager.m +++ b/packages/react-native/React/Modules/RCTUIManager.m @@ -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 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() @@ -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)