File tree 1 file changed +10
-5
lines changed
packages/react-native/React/Modules
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -179,15 +179,20 @@ - (void)setBridge:(RCTBridge *)bridge
179
179
_componentDataByName[componentData.name] = componentData;
180
180
}
181
181
}
182
-
182
+ // Preload the a11yManager as the RCTUIManager needs it to listen for notification
183
+ // By eagerly preloading it in the setBridge method, we make sure that the manager is
184
+ // properly initialized in the Main Thread and that we do not incur in any race condition
185
+ // or concurrency problem.
186
+ id <RCTBridgeModule> a11yManager = [self ->_bridge moduleForName: @" AccessibilityManager"
187
+ lazilyLoadIfNecessary: YES ];
188
+ __weak NSObject * a11yManagerWeakObject = a11yManager;
183
189
// This dispatch_async avoids a deadlock while configuring native modules
184
- dispatch_async (dispatch_get_global_queue (QOS_CLASS_USER_INTERACTIVE , 0 ), ^{
185
- id a11yManager = [self ->_bridge moduleForName: @" AccessibilityManager"
186
- lazilyLoadIfNecessary: YES ];
190
+ dispatch_async (dispatch_get_main_queue (), ^{
191
+ __strong NSObject * a11yManagerStrongObject = a11yManagerWeakObject;
187
192
[[NSNotificationCenter defaultCenter ] addObserver: self
188
193
selector: @selector (didReceiveNewContentSizeMultiplier )
189
194
name: @" RCTAccessibilityManagerDidUpdateMultiplierNotification"
190
- object: a11yManager ];
195
+ object: a11yManagerStrongObject ];
191
196
});
192
197
[[NSNotificationCenter defaultCenter ] addObserver: self
193
198
selector: @selector (namedOrientationDidChange )
You can’t perform that action at this time.
0 commit comments