Skip to content

Reuse initialized child nodes when building accessibility descriptions - #59748

Open
sorinc03 wants to merge 1 commit into
react:mainfrom
sorinc03:fix/android-accessibility-description-traversal
Open

sorinc03 wants to merge 1 commit into
react:mainfrom
sorinc03:fix/android-accessibility-description-traversal

Conversation

@sorinc03

@sorinc03 sorinc03 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses the repeated accessibility-description traversal reported in #59743.

getTalkbackDescription already initializes a child node to check speaking/focusability. Passing null into the recursive call creates and initializes that child again. If its delegate synthesizes a description, that repeats the subtree recursively.

Reuse the initialized child node instead. An eight-group/one-text regression fixture goes from 511 node initializations to 9 while retaining the same description. This does not gate accessibility on TalkBack, disable Content Capture, or add a persistent cache.

Changelog

[ANDROID] [FIXED] - Avoid redundant subtree initialization while generating accessibility descriptions

Test Plan

./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest \
  -Preact.internal.useHermesNightly=false \
  --tests com.facebook.react.uimanager.ReactAccessibilityDelegateTest
./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest \
  -Preact.internal.useHermesNightly=false

Java 17 and the Android SDK configured locally.

  • Before the production change: 22 focused tests, two expected traversal-count failures (nested counts 1/2/4/8/16/32/64/128/256, and an unlabelled wrapper initialized twice).
  • After: all 22 focused tests pass. Six added cases cover traversal counts, label order, focus/hidden boundaries, EditText text priority, disabled accessibility services, and fresh text on subsequent requests.
  • Full Debug JVM unit-test task passed: 863 tests across 119 suites, no failures/errors/skips. Repeated on final sources; parent review rerun completed up-to-date successfully.
  • Changed Kotlin formatting and git diff --check pass.

No physical Pixel was available. The reporter's release frame-time measurements are not measurements from this patch; Content Capture frame-time improvement and on-device TalkBack behavior still need confirmation. Existing speaking-descendant scans and separate per-view requests may still repeat work; this is not a claim of globally linear traversal.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 2, 2026
@sorinc03

sorinc03 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@LonelyCpp This removes the repeated child-node initialization described in your profile. The nested regression fixture goes from 511 initializations to 9 with the same description, and the full Debug JVM task passes 863 tests. I do not have a connected Pixel to measure Content Capture frame times; could you retest this change with your release-build A/B procedure and TalkBack enabled/disabled? The PR deliberately does not claim a measured device-frame improvement yet.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant