Skip to content

Commit

Permalink
perf(android): batch setupAccessibleView calls to improve TTI (#10391)
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Sep 28, 2023
1 parent 2cb26c2 commit a4bfbda
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/core/accessibility/index.android.ts
Expand Up @@ -442,13 +442,28 @@ export function setupAccessibleView(view: View): void {
updateAccessibilityProperties(view);
}

export function updateAccessibilityProperties(view: View): void {
let updateAccessibilityPropertiesMicroTask;
let pendingViews = new Set<View>();
export function updateAccessibilityProperties(view: View) {
if (!view.nativeViewProtected) {
return;
}

setAccessibilityDelegate(view);
applyContentDescription(view);
pendingViews.add(view);
if (updateAccessibilityPropertiesMicroTask) return;

updateAccessibilityPropertiesMicroTask = true;
Promise.resolve().then(() => {
updateAccessibilityPropertiesMicroTask = false;
let _pendingViews = Array.from(pendingViews);
pendingViews = new Set();
for (const view of _pendingViews) {
if (!view.nativeViewProtected) continue;
setAccessibilityDelegate(view);
applyContentDescription(view);
}
_pendingViews = [];
});
}

export function sendAccessibilityEvent(view: View, eventType: AndroidAccessibilityEvent, text?: string): void {
Expand Down

0 comments on commit a4bfbda

Please sign in to comment.