Fix crash when dispatching cancel events to reparented views - #55273
Closed
fabriziocucci wants to merge 1 commit into
Closed
Fix crash when dispatching cancel events to reparented views#55273fabriziocucci wants to merge 1 commit into
fabriziocucci wants to merge 1 commit into
Conversation
Summary: Changelog: [Internal] When `FloatingView` reparents its content to a `SurfaceControlViewHost` (for z-offset elevation), the child views are no longer descendants of the main React root view hierarchy. If a pointer cancel event is dispatched while the view is in this state, `JSPointerDispatcher.getChildOffsetRelativeToRoot()` calls `offsetDescendantRectToMyCoords()` which throws `IllegalArgumentException: parameter must be a descendant of this view`. This fix makes `getChildOffsetRelativeToRoot()` return `null` when the view is not a descendant (catching only the specific "descendant" exception), and skips dispatching the cancel event in that case while still cleaning up internal pointer state. This crash was occurring in IGVR when scrolling through story pogs with thumbstick input, as each pog uses `FloatingView` with elevation. Reviewed By: javache Differential Revision: D90988373
|
@fabriziocucci has exported this pull request. If you are a Meta employee, you can view the originating Diff in D90988373. |
Collaborator
|
This pull request was successfully merged by @fabriziocucci in 8544a68 When will my fix make it into a release? | How to file a pick request? |
|
This pull request has been merged in 8544a68. |
meta-codesync Bot
pushed a commit
that referenced
this pull request
Apr 2, 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 `IllegalArgumentException`s ## 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: - #32649 - #38925 - #7377 - kirillzyusko/react-native-keyboard-controller#961 - kirillzyusko/react-native-keyboard-controller#962 - dotnet/maui#32927 There is also precedent in RN for handling this class of non-descendant race defensively: - #55273 ## 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. Pull Request resolved: #56182 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. Reviewed By: jorge-cab Differential Revision: D97861147 Pulled By: Abbondanzo fbshipit-source-id: 15e624a94d5acd99777a7426787b52d8e85cdf8a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Changelog: [Internal]
When
FloatingViewreparents its content to aSurfaceControlViewHost(for z-offset elevation), the child views are no longer descendants of the main React root view hierarchy. If a pointer cancel event is dispatched while the view is in this state,JSPointerDispatcher.getChildOffsetRelativeToRoot()callsoffsetDescendantRectToMyCoords()which throwsIllegalArgumentException: parameter must be a descendant of this view.This fix makes
getChildOffsetRelativeToRoot()returnnullwhen the view is not a descendant (catching only the specific "descendant" exception), and skips dispatching the cancel event in that case while still cleaning up internal pointer state.This crash was occurring in IGVR when scrolling through story pogs with thumbstick input, as each pog uses
FloatingViewwith elevation.Reviewed By: javache
Differential Revision: D90988373