react-native: Fatal Exception: parameter must be a descendant of this view - ReactScrollView.java line 218
Description
I’m having a lot of crashes on Crashlytics related to ReactScrollView.java line 218 on Android.
The crashes appears first time on Nov 15, but I didn’t changes on my app.
Happen on Android: 8, 9, 10, 11 and 12. Samsung, Motorola, Google, LGE, OnePlus, etc.
Fatal Exception: java.lang.IllegalArgumentException: parameter must be a descendant of this view
at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:6272)
at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:6201)
at android.widget.ScrollView.isWithinDeltaOfScreen(ScrollView.java:1289)
at android.widget.ScrollView.onSizeChanged(ScrollView.java:1704)
at com.facebook.react.views.scroll.ReactScrollView.onSizeChanged(ReactScrollView.java:218)
at android.view.View.sizeChange(View.java:23088)
at android.view.View.setFrame(View.java:23040)
at android.view.View.layout(View.java:22897)
at android.view.ViewGroup.layout(ViewGroup.java:6389)
at com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout(NativeViewHierarchyManager.java:243)
at com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout(NativeViewHierarchyManager.java:211)
at com.facebook.react.uimanager.UIViewOperationQueue$UpdateLayoutOperation.execute(UIViewOperationQueue.java:161)
at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:917)
at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1028)
at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:48)
at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded(UIViewOperationQueue.java:986)
at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:31)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:250)
at android.app.ActivityThread.main(ActivityThread.java:7803)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
Version
0.63.4
Output of react-native info
System:
OS: macOS 12.0.1
CPU: (8) x64 Apple M1
Memory: 20.08 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.18.1 - /usr/local/bin/node
Yarn: Not Found
npm: 6.14.15 - /usr/local/bin/npm
Watchman: 4.9.0 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK:
API Levels: 28, 29, 30
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.3
System Images: android-30 | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7784292
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_282 - /usr/bin/javac
Python: 2.7.18 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: ~0.63.4 => 0.63.4
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
I don’t know, I’m seeing them on Crashlytics.
Snack, code example, screenshot, or link to a repository
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 27 (7 by maintainers)
Commits related to this issue
- Block descendant focus requests Resolves #55 See discussion https://github.com/facebook/react-native/issues/32649#issuecomment-990968256 — committed to TaylorDale/react-native-google-ads by TaylorDale 2 years ago
- fix: Block descendant focus requests * Block descendant focus requests See discussion https://github.com/facebook/react-native/issues/32649#issuecomment-990968256 — committed to invertase/react-native-google-mobile-ads by TaylorDale 2 years ago
- chore(release): 4.0.2 [skip ci] ### [4.0.2](https://github.com/invertase/react-native-google-ads/compare/v4.0.1...v4.0.2) (2022-01-24) ### Bug Fixes * Block descendant focus requests ([e39a5fd](htt... — committed to invertase/react-native-google-mobile-ads by semantic-release-bot 2 years ago
- fix: Block descendant focus requests * Block descendant focus requests See discussion https://github.com/facebook/react-native/issues/32649#issuecomment-990968256 — committed to invertase/react-native-google-mobile-ads by TaylorDale 2 years ago
- chore(release): 4.0.2 [skip ci] ### [4.0.2](https://github.com/invertase/react-native-google-ads/compare/v4.0.1...v4.0.2) (2022-01-24) ### Bug Fixes * Block descendant focus requests ([e39a5fd](htt... — committed to invertase/react-native-google-mobile-ads by semantic-release-bot 2 years ago
- chore(release): 4.0.0 [skip ci] ## [4.0.0](https://github.com/invertase/react-native-google-mobile-ads/compare/v3.4.0...v4.0.0) (2022-02-07) ### ⚠ BREAKING CHANGES * typescript rewrite (#41) ### F... — committed to invertase/react-native-google-mobile-ads by semantic-release-bot 2 years ago
- chore(release): 4.0.0 [skip ci] ## [4.0.0](https://github.com/invertase/react-native-google-mobile-ads/compare/v3.4.0...v4.0.0) (2022-02-07) ### ⚠ BREAKING CHANGES * typescript rewrite (#41) ### F... — committed to invertase/react-native-google-mobile-ads by semantic-release-bot 2 years ago
- fix crash ScrollView - "parameter must be a descendant of this view" https://github.com/facebook/react-native/issues/32649 — committed to mondadori-digital/react-native-gam by aknad 2 years ago
I can confirm this problem happen because sometimes the Ad displayed is a WebView under the hood, and WebView itself will trigger a focus request.
If you are using the last version of https://github.com/react-native-admob/admob here’s a small patch fixing this bug :
Thanks so much @manuhook and @RodolfoGS - using the patch described above has prevented this crash for us in our latest release.
There is an update too in the Google Ads SDK forum that might be useful to anyone who isn’t easily able to update or patch their Ads SDK native Android code. It seems disabling the specific
autopromotioncampaign(s?) setup forbackfillmay also prevent the crash.Yes @julianD77, no more crashes related to this error after applying the patch.
Thank you so much @manuhook! Here is the patch for
@react-native-firebase/admob: 11.5.0. Note: I’m not tested yet!File:
patches/@react-native-firebase+admob+11.5.0.patchThanks for this @manuhook - have you confirmed that this does reduce the crash for users of your App? We are going to try and release an update with this workaround today
Reported on the Google Ads SDK forum here: https://groups.google.com/g/google-admob-ads-sdk/c/EsLEaoRjyNM
We dont yet have the data for App usage with the updated Google Ads SDK but do now have data for a period when Ads have been fully disabled (from around 1am) and not served to the App, and can see from this chart that it does have an effect on the frequency of this crash:
We are still trying to verify this and aiming to get a new release out with just an update to use v20.5.0 the Ads SDK today. Will update as soon as I can.
@mqueiroz1995 See
facebook.react.uimanager.NativeViewHierarchyManager.updateLayoutin the call stack above. This just ends up triggering method calls on theViewGroupclass which is as you say native Android code. The issue I think is how the view hierarchy is getting modified to lead to the case whereparameter must be a descendant of this viewis no longer true.Hey @julianD77 , we are facing the same issue in our production app. Was updating Google Ads effective?
Id definitely suggest trying a release with updated
-adsdependencies. I’ll update here if we determine that disabling Android Ads / updating the SDKs has affected the frequency of this crash for us.