Conversation
…accessibilityCollectionItem onInitializeAccessibilityEventInternal read a child's accessibility_collection_item tag with a non-null `as` cast into a nullable variable, even though the code right below handles the null case (checking one nested child, for FlatList without getItemLayout). When a ScrollView has accessibilityCollection set and any direct child of its content view has no accessibilityCollectionItem tag, e.g. a FlatList ListHeaderComponent or ListFooterComponent, the cast throws NullPointerException. With TalkBack on this crashes the app, for example when Fabric removes the accessibility-focused view on navigation and the resulting event reaches the delegate. Use `as?` so the existing null handling runs as intended, matching the other tag reads in this file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cortinico
approved these changes
Sep 24, 2026
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this in D121556760. |
This branch has not been deployed
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:
With TalkBack on, a
ScrollViewthat hasaccessibilityCollectionset crashes the app as soon as any direct child of its content view lacksaccessibilityCollectionItem— e.g. a FlatListListHeaderComponentorListFooterComponent. It reproduces on a common path: a screen reader user navigating away from a list screen. In release builds there is no red box; the process just dies.The cause is a non-null cast on a value the code expects to be null:
The variable is declared nullable and the null branch right below it was written for exactly this case, but the
ascast throws before that branch can run. This PR changes it toas?, matching the other tag reads in the same file. No behavior change for children that do carry the tag.It has gone unnoticed because no React Native component sets
accessibilityCollectionitself (it was added in 105a239 for #30977), so the early return at the top of the method skips this code for core lists. Any library that sets it to announce a windowed list's real length hits the crash immediately. Observed on 0.87.1 (API 36, new architecture, Hermes); details in iray-tno/hozo#512.Changelog:
[ANDROID] [FIXED] - Fix crash in ScrollView accessibility delegate when
accessibilityCollectionis set and a child (e.g. a list header or footer) has noaccessibilityCollectionItemTest Plan:
as→as?); the assigned variable is alreadyReadableMap?and all later uses are null-checked, so types are unchanged.FlatListwithListHeaderComponent,accessibilityCollectionon the list andaccessibilityCollectionItemon cells only; put accessibility focus inside the list and unmount the screen → crash above. Expected after: no crash.🤖 Generated with Claude Code