react-native-pager-view: App Crash - UIViewControllerHierarchyInconsistency
Bug
When i open the app, it crashes sometimes ( %20 crash rate ) There is no log on console, Flipper can’t catch any error, Only Crashlytics catches the error.
- Android is working very well.
- There is no problem on version 3.3.0
react-native info
output:
System:
OS: macOS 10.15.3
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 162.63 MB / 8.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.11.1 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.14.5 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 11.3.1/11C505 - /usr/bin/xcodebuild
Languages:
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
Library version: 4.0.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 58 (17 by maintainers)
This seems to have to reappeared (5.4.0 + iOS).
I narrowed down the problem in my case to version 4.1.0.
4.0.1: works as expected 4.1.0: throws the ViewController error above and the app crashes.
I had the same issue and @farad4y patch fixed it. Here is the patch created using patch-package:
This issue has been fixed here: https://github.com/callstack/react-native-pager-view/releases/tag/v5.4.1
Also experiencing this on iOS. I tried reproducing in a sample project, but was not successful.
Here is a rough description of my setup:
I have a react-navigation TabNavigationController with three tabs, first and last have a ViewPager. Both use the same wrapper around ViewPager, with the following snippet:
On startup when the initial tab is the third one (I guess otherwise it just renders the first tab) I get the crash. However, I can fix it when replacing the above snippet with the following:
I hope this might help resolve the issue!
Had also the same problem, I used
requestAnimationFrame(() => refViewPager.current?.setPage(index));
to avoid the exception.Currently experiencing this issue
I’m trying to integrate a dialog component inside one of the pages. It works well on android. But not on iOS. I’m trying to find the cause. I tried to place my dialog component on its parent module. but still the same. Someone might know a fix or any advise? Thanks!
I reopening this issue, because bug still exist
There may be a race condition causing this crash.
In
ReactNativePageView.m
thecreateChildViewController
is called with the same array of UIViews (self.reactSubviews
) fromrenderChildrenViewControllers
andaddPages
.The @farad4y 's patch fixes the issue because
addSubview
removes the previous superview if needed before adding it to the new superview.@troZee I replaced childViewController.view = view; to [childViewController.view addSubview: view]; then issue is solved
I can’t provide any reproducible example right now, i have to create a new project for this
LGTM. Tested 5 times without crash. Gesture was fixed.
I tested. Looks no crash (it not 100% reproducable for me so tested 6 times without errors). But I can’t change page by gesture with this code.
Also faced the same problem
Can you try to change:
into:
Also faced the same problem. omg i hope this fixes.
Have upgraded to “@react-native-community/viewpager”: “^4.1.3”, and will monitor
I’m facing the same problem. I’ll try to upgrade the version and see if it’s fixed.
Extra info: We use redux-offline. When i disable redux-online, works perfectly. This is really strange because there is no problem on version 3.3.0