Skip to content

Fix Android accessibility descendant race in ReactViewGroup#56182

Closed
erickreutz wants to merge 2 commits intofacebook:mainfrom
erickreutz:eric/fix-android-a11y-descendant-crash
Closed

Fix Android accessibility descendant race in ReactViewGroup#56182
erickreutz wants to merge 2 commits intofacebook:mainfrom
erickreutz:eric/fix-android-a11y-descendant-crash

Conversation

@erickreutz
Copy link
Copy Markdown
Contributor

@erickreutz erickreutz commented Mar 22, 2026

Summary

Guard ReactViewGroup.addChildrenForAccessibility against transient non-descendant races during accessibility traversal on Android.

This replaces direct super.addChildrenForAccessibility(...) calls with a small wrapper that:

  • catches IllegalArgumentException
  • only swallows the specific "descendant of this view" case
  • rethrows all other IllegalArgumentExceptions

Why

There are recurring crashes with stack traces ending in:
ViewGroup.offsetRectBetweenParentAndChild -> offsetDescendantRectToMyCoords -> addChildrenForAccessibility -> IllegalArgumentException: parameter must be a descendant of this view.

This can happen when accessibility is traversing children while views are being re-parented/removed.

Related reports:

There is also precedent in RN for handling this class of non-descendant race defensively:

Scope

This is intentionally minimal and localized to accessibility child collection in ReactViewGroup. Behavior is unchanged in the non-racy path.

Changelog:

[Android] [Fixed] - Guard ReactViewGroup.addChildrenForAccessibility against transient non-descendant accessibility traversal crashes.

Test Plan:

Validated in a downstream RN Android app on Android 16 with repeated sheet/modal open-close stress and active accessibility hierarchy traversal; crash reproduces before patch and no longer reproduces with this guard.

@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 Mar 22, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Mar 22, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Mar 24, 2026

@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D97861147.

@meta-codesync meta-codesync Bot closed this in e681736 Apr 2, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Apr 2, 2026

@Abbondanzo merged this pull request in e681736.

@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Apr 2, 2026
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @erickreutz in e681736

When will my fix make it into a release? | How to file a pick request?

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. Merged This PR has been merged. 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.

3 participants