Skip to content

Commit ea2ca1b

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Run RCTAccessibilityManager methods on the main queue (#58476)
Summary: Pull Request resolved: #58476 RCTAccessibilityManager mirrors UIKit accessibility state into ivars from nine NSNotificationCenter handlers, which are delivered on the main thread. The module declared no methodQueue, so its exported methods ran on the JS thread instead, and none of its properties are atomic. That leaves the content size multipliers open to a data race. The `multipliers` getter lazily assigns `_multipliers` on read and is reached from the main thread via the content size category notification, while `setAccessibilityContentSizeMultipliers:` reaches `setMultipliers:` from the JS thread and releases the previous dictionary. Concurrent access can over-release that dictionary and leave a dangling pointer behind, which then faults on the next message to it. Declare methodQueue as the main queue so the exported methods and the notification handlers serialize on one thread. The module already requires main queue setup and every method reads UIKit-derived state, so this matches how it is used. Changelog: [iOS][Fixed] - Fix data race on accessibility content size multipliers in `RCTAccessibilityManager` Reviewed By: javache Differential Revision: D119565016 fbshipit-source-id: 53cee1f9f5984519964e0e8fa8df12f1e7fa88f7
1 parent be53e3a commit ea2ca1b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/react-native/React/CoreModules/RCTAccessibilityManager.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ + (BOOL)requiresMainQueueSetup
4040
return YES;
4141
}
4242

43+
- (dispatch_queue_t)methodQueue
44+
{
45+
return dispatch_get_main_queue();
46+
}
47+
4348
- (instancetype)init
4449
{
4550
if (self = [super init]) {

0 commit comments

Comments
 (0)