Skip to content

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
kkafar added a commit that referenced this pull request Jan 16, 2025
## Description

This PR removes the workaround introduced in series of PRs (listed
chronologically here):

1. #2307
2. #2383
3. #2495
4. #2531

For detailed description of error mechanism and broader discussion
please refer to:

1. [my comment on
#2495](#2495 (comment)),
2. [my fix to RN
core](facebook/react-native#47634)

tldr: When popping screen on Fabric we marked the views as
"transitioning" and this led to view being effectively miscounted
during removal by view groups that supported react-native's subview
clipping mechanism.

The issue has been present most likely in every version of the library
when running on Android & Fabric, but it arose few months ago due to
broader
adoption of the new architecture.

facebook/react-native#47634 is supposed to fix
the underlying issue in `react-native's` core.

## Changes

Removed the workaround code from `Screen` implementation on Android.

The 

* facebook/react-native#47634

has been released with 0.77.0-rc.3 and followup small fixup:

* facebook/react-native#48329

has been released with 0.77.0-rc.4.

Therefore, with landing this PR we should limit our support on Fabric to
0.77.0.

## Test code and steps to reproduce

`Test2282` - note that there are few testing variants available there,
you just need to comment (out) some parts of the code.

## Checklist

- [x] Included code example that can be used to test this change
- [ ] Ensured that CI passes
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

3 participants