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

Fatal Exception: parameter must be a descendant of this view - ReactScrollView.java line 218 #32649

Closed
RodolfoGS opened this issue Nov 24, 2021 · 27 comments
Labels
Component: ScrollView Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@RodolfoGS
Copy link
Contributor

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

@julianD77
Copy link

julianD77 commented Nov 24, 2021

We are also experiencing this same issue. Have you made any more headway when investigating it?

We are currently investigating whether it might be related to UI issues where some of our components are rendered off the screen in a scrollable view. Or whether it could be due to some improper handling of the device safe area boundaries.

  npmPackages:
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.2 => 0.64.2 

@RodolfoGS
Copy link
Contributor Author

@julianD77 I don't know how to reproduce it. The major concern is that I didn't made changes on my app and I didn't have anyone of these crashes before November 15th, but since nov 15 I've a lot of them

Last 30 days chart:
image

@julianD77
Copy link

Hmm that's very interesting - our graph is very similar.

Do you use Google Ads? We do and Im wondering if that could be related to this due to it being something potentially outside of our control that could have resulted in changed behaviour/appearance.

We also haven't yet identified a change in our code or dependencies that could have triggered this.

Screenshot 2021-11-24 at 16 37 11

@RodolfoGS
Copy link
Contributor Author

Mmm yes, I'm using Google Ads too and your chart is sooo similar

@julianD77
Copy link

What version of the Ads dependencies are you using? These are the relevant versions we have:

com.google.ads.mediation:facebook:6.5.1.0@aar
com.google.android.gms:play-services-ads:20.2.0@aar
com.google.android.gms:play-services-ads-lite:20.2.0@aar
com.google.android.gms:play-services-base:17.5.0@aar
com.google.android.gms:play-services-ads-base:20.2.0@aar
com.google.android.gms:play-services-ads-identifier:17.0.0@aar
com.google.android.gms:play-services-basement:17.6.0@aar
androidx.appcompat:appcompat:1.3.1@aar
com.facebook.react:react-native:0.64.2@aar

We are checking now if disabling Ads through Ad Manager does help affect this crash. Hopefully we will know within a couple of hours. Will also:

  • try and push out a release with all the Ads related dependencies updated
  • try updating the App to a newer RN version, likely 0.65.1 initially

Have you had any further insights/plans to address this/thoughts on where else we might get more information to help with this issue?

@RodolfoGS
Copy link
Contributor Author

My dependencies are little older than yours:

com.google.android.gms:play-services-ads:19.8.0
com.google.android.gms:play-services-ads-base:19.8.0
com.google.android.gms:play-services-ads-identifier:17.0.0
com.google.android.gms:play-services-ads-lite:19.8.0
com.google.android.ads.consent:consent-library:1.0.6

I can't upgrade to latest version of RN since I'm using expo, and the latest version supported is 0.64. So, I didn't do anything for now, I don't know what can I do :/

@julianD77
Copy link

Id definitely suggest trying a release with updated -ads dependencies. I'll update here if we determine that disabling Android Ads / updating the SDKs has affected the frequency of this crash for us.

@Pingou
Copy link

Pingou commented Nov 27, 2021

Same issue here. Cannot update Admob for now as I'm waiting for react native firebase to support the new version of Admob.

@mqueiroz1995
Copy link

Hey @julianD77 , we are facing the same issue in our production app. Was updating Google Ads effective?

@mqueiroz1995
Copy link

Curiosly, despite using RN in our app, the stacktraces have no mention to React Native classes and the logs are indicating the problem occurs in a fully native feature. The ocurrencies also started on November 15th and also seems to be unrelated to any of our releases. We have Google Ads in our app.

@julianD77
Copy link

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.updateLayout in the call stack above. This just ends up triggering method calls on the ViewGroup class 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 where parameter must be a descendant of this view is no longer true.

@julianD77
Copy link

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:

Screenshot 2021-12-01 at 09 20 40

@julianD77
Copy link

Reported on the Google Ads SDK forum here: https://groups.google.com/g/google-admob-ads-sdk/c/EsLEaoRjyNM

@manuhook
Copy link

manuhook commented Dec 6, 2021

Same problem here even using the last version of Google Ads.
The crash occurs when the app goes into background and comes back to the foreground.
Seems to be an ad focus problem

@0xRomain
Copy link

0xRomain commented Dec 6, 2021

Same things here since the 15 nov

@RodolfoGS
Copy link
Contributor Author

Hi @julianD77, Do you experimented improvements after upgrade Google Ads sdk to the latest version? Thanks

@julianD77
Copy link

Unfortunately it appears that updating the Google Ads SDK to 20.5.0 has not made much of a difference to this crash - the number of these daily crashes is staying roughly the same after the SDK update.

The only time the frequency of this crash dropped was when we paused Ads from being served to the Apps.

Since we cannot keep Ads disabled to prevent this crash our next option is to update to a later React Native version to see if this issue is then resolved.

Can others comment on the version of React-Native and Ads SDK that you are currently using when users are experiencing this crash please?

Our app is using

react-native: 0.64.2 
play-services-ads-lite: 20.5.0

@RodolfoGS
Copy link
Contributor Author

Thanks for your updates @julianD77!

What library you are using to implement google ads in your react native app?, I'm using @react-native-firebase/admob: 11.5.0, maybe could be there the bug?

I'm using:

react: 17.0.1
react-native: 0.64.2
@react-native-firebase/admob: 11.5.0
com.google.android.gms:play-services-ads:19.8.0
com.google.android.gms:play-services-ads-base:19.8.0
com.google.android.gms:play-services-ads-identifier:17.0.0
com.google.android.gms:play-services-ads-lite:19.8.0
com.google.android.ads.consent:consent-library:1.0.6

Someone with react native > 0.64 there?

@mqueiroz1995
Copy link

We are using react-native: "0.66.1" and facing the issue.

Also:

    googlePlayServicesVersion = '17.0.0'
    googlePlayServicesAdsVersion = '19.8.0'
    googlePlayServicesAuthVersion = '17.0.0'
    googlePlayServicesLocationVersion = '17.0.0'
    googlePlayServicesAdsIdentifierVersion = '17.0.0'
    googlePlayServicesAnalytics = '17.0.0'
    googlePlayServicesTagManager = '17.0.0'

@RodolfoGS
Copy link
Contributor Author

@mqueiroz1995 What are you using to implement in react native?, are you using @react-native-firebase/admob?

@manuhook
Copy link

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 :

diff --git a/node_modules/@react-native-admob/admob/android/src/main/java/com/rnadmob/admob/ads/banner/RNAdMobBannerView.java b/node_modules/@react-native-admob/admob/android/src/main/java/com/rnadmob/admob/ads/banner/RNAdMobBannerView.java
index 573e3d8..c372d51 100644
--- a/node_modules/@react-native-admob/admob/android/src/main/java/com/rnadmob/admob/ads/banner/RNAdMobBannerView.java
+++ b/node_modules/@react-native-admob/admob/android/src/main/java/com/rnadmob/admob/ads/banner/RNAdMobBannerView.java
@@ -8,6 +8,7 @@ import static com.rnadmob.admob.ads.banner.RNAdMobBannerViewManager.EVENT_APP_EV
 import static com.rnadmob.admob.ads.banner.RNAdMobBannerViewManager.EVENT_SIZE_CHANGE;
 
 import android.content.Context;
+import android.view.ViewGroup;
 
 import com.facebook.react.bridge.Arguments;
 import com.facebook.react.bridge.ReadableArray;
@@ -49,6 +50,7 @@ public class RNAdMobBannerView extends ReactViewGroup implements AppEventListene
             adView.destroy();
         }
         adView = new AdManagerAdView(getContext());
+        adView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
         adView.setAdListener(new AdListener() {
             @Override
             public void onAdLoaded() {

@julianD77
Copy link

Thanks 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

@RodolfoGS
Copy link
Contributor Author

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.patch

diff --git a/node_modules/@react-native-firebase/admob/android/src/main/java/io/invertase/firebase/admob/ReactNativeFirebaseAdMobBannerAdViewManager.java b/node_modules/@react-native-firebase/admob/android/src/main/java/io/invertase/firebase/admob/ReactNativeFirebaseAdMobBannerAdViewManager.java
index 5faee1b..58b61c0 100644
--- a/node_modules/@react-native-firebase/admob/android/src/main/java/io/invertase/firebase/admob/ReactNativeFirebaseAdMobBannerAdViewManager.java
+++ b/node_modules/@react-native-firebase/admob/android/src/main/java/io/invertase/firebase/admob/ReactNativeFirebaseAdMobBannerAdViewManager.java
@@ -32,6 +32,7 @@ import com.google.android.gms.ads.AdRequest;
 import com.google.android.gms.ads.AdSize;
 import com.google.android.gms.ads.AdView;
 
+import android.view.ViewGroup;
 import javax.annotation.Nonnull;
 import java.util.Map;
 
@@ -121,7 +122,7 @@ public class ReactNativeFirebaseAdMobBannerAdViewManager extends SimpleViewManag
 
   private void setAdListener(ReactViewGroup reactViewGroup) {
     final AdView adView = getAdView(reactViewGroup);
-
+    adView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
     adView.setAdListener(new AdListener() {
       @Override
       public void onAdLoaded() {

@manuhook
Copy link

Yes @julianD77, no more crashes related to this error after applying the patch.

@julianD77
Copy link

julianD77 commented Dec 14, 2021

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 autopromotion campaign(s?) setup for backfill may also prevent the crash.

Hello, I have found the cause of the bug. It turns out that the bug started to appear when I created an autopromotion campaign for backfill. It must be a bug.

Thanks for the help and it was hard to find the bug. I found it by chance. As soon as I deleted the campaign, it started showing ads again.

dylancom pushed a commit to invertase/react-native-google-mobile-ads that referenced this issue Jan 24, 2022
* Block descendant focus requests

See discussion facebook/react-native#32649 (comment)
github-actions bot pushed a commit to invertase/react-native-google-mobile-ads that referenced this issue Jan 24, 2022
### [4.0.2](v4.0.1...v4.0.2) (2022-01-24)

### Bug Fixes

* Block descendant focus requests ([e39a5fd](e39a5fd)), closes [/github.com/facebook/react-native/issues/32649#issuecomment-990968256](https://github.com/invertase//github.com/facebook/react-native/issues/32649/issues/issuecomment-990968256)
* typo in native event type ([3cfc1ff](3cfc1ff))
mikehardy pushed a commit to invertase/react-native-google-mobile-ads that referenced this issue Feb 7, 2022
* Block descendant focus requests

See discussion facebook/react-native#32649 (comment)
mikehardy pushed a commit to invertase/react-native-google-mobile-ads that referenced this issue Feb 7, 2022
### [4.0.2](v4.0.1...v4.0.2) (2022-01-24)

### Bug Fixes

* Block descendant focus requests ([e39a5fd](e39a5fd)), closes [/github.com/facebook/react-native/issues/32649#issuecomment-990968256](https://github.com/invertase//github.com/facebook/react-native/issues/32649/issues/issuecomment-990968256)
* typo in native event type ([3cfc1ff](3cfc1ff))
github-actions bot pushed a commit to invertase/react-native-google-mobile-ads that referenced this issue Feb 7, 2022
## [4.0.0](v3.4.0...v4.0.0) (2022-02-07)

### ⚠ BREAKING CHANGES

* typescript rewrite (#41)

### Features

* app open ads ([6be7d02](6be7d02))
* typescript rewrite ([#41](#41)) ([4114e4b](4114e4b))

### Bug Fixes

* **android:** no banner ads loaded in the first render ([3154579](3154579))
* Block descendant focus requests ([835bdec](835bdec)), closes [/github.com/facebook/react-native/issues/32649#issuecomment-990968256](https://github.com/invertase//github.com/facebook/react-native/issues/32649/issues/issuecomment-990968256)
* point to the right native module ([df30e7b](df30e7b))
* **release:** allow semantic-release on beta branch ([106ce63](106ce63))
* typo in native event type ([fcb911a](fcb911a))
github-actions bot pushed a commit to invertase/react-native-google-mobile-ads that referenced this issue Feb 7, 2022
## [4.0.0](v3.4.0...v4.0.0) (2022-02-07)

### ⚠ BREAKING CHANGES

* typescript rewrite (#41)

### Features

* app open ads ([6be7d02](6be7d02))
* typescript rewrite ([#41](#41)) ([4114e4b](4114e4b))

### Bug Fixes

* **android:** no banner ads loaded in the first render ([3154579](3154579))
* Block descendant focus requests ([835bdec](835bdec)), closes [/github.com/facebook/react-native/issues/32649#issuecomment-990968256](https://github.com/invertase//github.com/facebook/react-native/issues/32649/issues/issuecomment-990968256)
* **CHANGELOG:** remove duplicate changelog chunk ([d5e59e3](d5e59e3))
* point to the right native module ([df30e7b](df30e7b))
* **release:** allow semantic-release on beta branch ([106ce63](106ce63))
* typo in native event type ([fcb911a](fcb911a))
aknad added a commit to mondadori-digital/react-native-gam that referenced this issue Feb 16, 2022
@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 16, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@facebook facebook locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: ScrollView Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

7 participants