Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Android): prevent crash when we can not insert any subviews into child #2531

Merged
merged 2 commits into from
Nov 21, 2024

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Nov 21, 2024

Description

Attempt to patch changes from #2495. It improved the situation in most of the cases
but caused crashes in cases where we tried to insert subviews into viewgroups that have any kind of assertions on their child count, e.g. NestedScrollView or ViewPager.

Fixes #2529
Supersedes #2527

Changes

In this PR I do two things:

  • apply the workaround only to views that could actually have clipped subviews
  • catch any kind of exception thrown on view insertion; if one is thrown we stop to add subviews for given child

Test code and steps to reproduce

Test2282 works in both configurations (complex screen with nested flatlists + my simple reproduction of the issue)

Checklist

@hirbod
Copy link
Contributor

hirbod commented Nov 21, 2024

I can confirm that this PR fixed the crash with NestedHorizontalScrollViews

@kkafar kkafar merged commit 6aaf56b into main Nov 21, 2024
4 checks passed
@kkafar kkafar deleted the @kkafar/crash-on-stub-view-insertion branch November 21, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

after react-native-screens 4.2.0 upgrade, app crashes with viewpager2 does not support direct child views
2 participants