Skip to content

Commit 04bf38c

Browse files
authored
-[RCTAccessibilityManager announceForAccessibility:] calls into AppKit from background thread (#1852)
Specifically, NSAccessibilityPostNotificationWithUserInfo. Other methods such as `getCurrentHighContrastState` provide cached state (cached on main thread via `observeValueForKeyPath` et al). Some other methods such as `setAccessibilityFocus` dispatch to the main thread. Not doing so could lead to AppKit further firing selectors on UI logic in app code and lead to downstream issues.
1 parent 54940e4 commit 04bf38c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

React/Modules/MacOS/RCTAccessibilityManager.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ - (void)dealloc
6060

6161
RCT_EXPORT_METHOD(announceForAccessibility:(NSString *)announcement)
6262
{
63+
dispatch_async(dispatch_get_main_queue(), ^{
6364
NSAccessibilityPostNotificationWithUserInfo(
6465
NSApp,
6566
NSAccessibilityAnnouncementRequestedNotification,
6667
@{NSAccessibilityAnnouncementKey : announcement,
6768
NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh)
6869
}
6970
);
71+
});
7072
}
7173

7274
RCT_EXPORT_METHOD(getCurrentHighContrastState:(RCTResponseSenderBlock)callback
@@ -161,4 +163,4 @@ - (void)accessibilityDisplayOptionsChange:(NSNotification *)notification
161163
}
162164

163165
@end
164-
#endif
166+
#endif

0 commit comments

Comments
 (0)