googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.37k stars 1.08k forks source link

Admob 7.3.0 Crash on Samsung Z Flip 3, similar crash also happens to hundreds of users (reported by Firebase Crashlytic) #2342

Closed jacattrongnlh closed 1 year ago

jacattrongnlh commented 2 years ago

Step 0: Are you in the right place?

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

Follow Admob's instructions on how to implement Interstitial https://developers.google.com/admob/unity/interstitial

Build APK.

Open the app, request and show an interstitial ad.

Close the interstitial ad, the app crashes.

Stacktrace I got from logcat: Full stacktrace

<google-sheets-html-origin><style type="text/css"><!--td {border: 1px solid #cccccc;}br {mso-data-placement:same-cell;}--></style>

2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.SecurityException: listen
--
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at java.lang.Exception android.os.Parcel.createExceptionOrNull(int, java.lang.String) (Parcel.java:2437)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at java.lang.Exception android.os.Parcel.createException(int, java.lang.String) (Parcel.java:2421)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void android.os.Parcel.readException(int, java.lang.String) (Parcel.java:2404)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void android.os.Parcel.readException() (Parcel.java:2346)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void com.android.internal.telephony.ITelephonyRegistry$Stub$Proxy.listenWithEventList(int, java.lang.String, java.lang.String, com.android.internal.telephony.IPhoneStateListener, int[], boolean) (ITelephonyRegistry.java:1036)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void android.telephony.TelephonyRegistryManager.listenFromListener(int, java.lang.String, java.lang.String, android.telephony.PhoneStateListener, int, boolean) (TelephonyRegistryManager.java:250)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void android.telephony.TelephonyManager.listen(android.telephony.PhoneStateListener, int) (TelephonyManager.java:6798)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void com.unity3d.player.UnityPlayer.addPhoneCallListener() ((null):-1)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) ((null):-1)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) ((null):-1)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:226)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void android.os.Looper.loop() (Looper.java:313)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]   at void com.unity3d.player.UnityPlayer$e.run() ((null):-1)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594] Caused by: android.os.RemoteException: Remote stack trace:
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594] (Throwable with no stack trace)
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]     in call to CallVoidMethodV
2022/10/20 12:02:58.468 15303 15342 Fatal dmobNothingTes java_vm_ext.cc:594]     from boolean com.unity3d.player.UnityPlayer.nativeRender()

Relevant Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GoogleMobileAds.Api;
using System;

namespace Omnilatent.AdsMediation.Example
{
    public class AdsTesterOmni : MonoBehaviour
    {
        private InterstitialAd interstitial;
        private RewardedAd rewardedAd;
        private BannerView bannerView;
        [SerializeField] InputField debugTextField;

        private void Start()
        {
            Application.logMessageReceived += OnLog;
        }

        private void OnLog(string msg, string stackTrace, LogType type)
        {
            SetText(msg + "\n" + stackTrace);
        }

        public void RequestIntersitial()
        {
#if UNITY_ANDROID
        string adUnitId = "ca-app-pub-3940256099942544/1033173712";
#elif UNITY_IPHONE
        string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
            string adUnitId = "unexpected_platform";
#endif

            // Initialize an InterstitialAd.
            this.interstitial = new InterstitialAd(adUnitId);
            // Create an empty ad request.
            AdRequest request = new AdRequest.Builder().Build();
            // Load the interstitial with the request.
            this.interstitial.LoadAd(request);
        }

        public void ShowInter()
        {
            if (this.interstitial.IsLoaded())
            {
                this.interstitial.Show();
            }
        }

        public void TestReward1()
        {
            this.rewardedAd = new RewardedAd("ca-app-pub-3940256099942544/5224354917");

            this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
            // Called when an ad request failed to load.
            this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
            // Called when an ad is shown.
            this.rewardedAd.OnAdOpening += HandleRewardedAdOpening;
            // Called when an ad request failed to show.
            this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
            // Called when the user should be rewarded for interacting with the ad.
            this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
            // Called when the ad is closed.
            this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;

            // Create an empty ad request.
            AdRequest request = new AdRequest.Builder().Build();
            // Load the rewarded ad with the request.
            this.rewardedAd.LoadAd(request);
        }

        public void HandleRewardedAdLoaded(object sender, EventArgs args)
        {
            MonoBehaviour.print("HandleRewardedAdLoaded event received");
            this.rewardedAd.Show();
        }

        public void HandleRewardedAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
        {
            MonoBehaviour.print(
                "HandleRewardedAdFailedToLoad event received with message: "
                                 + args.LoadAdError.GetMessage());
        }

        public void HandleRewardedAdOpening(object sender, EventArgs args)
        {
            MonoBehaviour.print("HandleRewardedAdOpening event received");
        }

        public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
        {
            MonoBehaviour.print(
                "HandleRewardedAdFailedToShow event received with message: "
                                 + args.AdError.GetMessage());
        }

        public void HandleRewardedAdClosed(object sender, EventArgs args)
        {
            MonoBehaviour.print("HandleRewardedAdClosed event received");
        }

        public void HandleUserEarnedReward(object sender, Reward args)
        {
            string type = args.Type;
            double amount = args.Amount;
            MonoBehaviour.print(
                "HandleRewardedAdRewarded event received for "
                            + amount.ToString() + " " + type);
        }

        void SetText(string text)
        {
            debugTextField.text = text;
        }

        public void RequestBanner()
        {
            // These ad units are configured to always serve test ads.
#if UNITY_EDITOR
            string adUnitId = "unused";
#elif UNITY_ANDROID
            string adUnitId = "ca-app-pub-3212738706492790/6113697308";
#elif UNITY_IPHONE
            string adUnitId = "ca-app-pub-3212738706492790/5381898163";
#else
            string adUnitId = "unexpected_platform";
#endif

            // Clean up banner ad before creating a new one.
            if (this.bannerView != null)
            {
                this.bannerView.Destroy();
            }

            AdSize adaptiveSize =
                    AdSize.GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(AdSize.FullWidth);

            this.bannerView = new BannerView(adUnitId, adaptiveSize, AdPosition.Bottom);

            // Register for ad events.
            this.bannerView.OnAdLoaded += this.HandleAdLoaded;
            this.bannerView.OnAdFailedToLoad += this.HandleAdFailedToLoad;
            this.bannerView.OnAdOpening += this.HandleAdOpening;
            this.bannerView.OnAdClosed += this.HandleAdClosed;

            AdRequest adRequest = new AdRequest.Builder()
                .Build();

            // Load a banner ad.
            this.bannerView.LoadAd(adRequest);
        }

        #region Banner callback handlers

        public void HandleAdLoaded(object sender, EventArgs args)
        {
            MonoBehaviour.print("HandleAdLoaded event received");
            MonoBehaviour.print(String.Format("Ad Height: {0}, width: {1}",
                this.bannerView.GetHeightInPixels(),
                this.bannerView.GetWidthInPixels()));
            bannerView.Show();
        }

        public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
        {
            MonoBehaviour.print(
                    "HandleFailedToReceiveAd event received with message: " + args.LoadAdError.GetMessage());
        }

        public void HandleAdOpening(object sender, EventArgs args)
        {
            MonoBehaviour.print("HandleAdOpening event received");
        }

        public void HandleAdClosed(object sender, EventArgs args)
        {
            MonoBehaviour.print("HandleAdClosed event received");
        }

        #endregion
    }
}

Firebase crashlytic:

Firebase grouped the above mentioned crash in libc.so crash, this is what Firebase logged:

Crashed: Thread #1
SIGABRT 0x0000000000000000
0
libc.so
(Missing UUID 0f39fc790debeef5bc191987ab30a3f5)
1
libc.so
(Missing UUID 0f39fc790debeef5bc191987ab30a3f5)
2
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
3
libbase.so
(Missing UUID b77c57f68a484ed93d5a7eda59d83bf9)
4
libbase.so
(Missing UUID b77c57f68a484ed93d5a7eda59d83bf9)
5
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
6
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
7
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
8
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
9
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
10
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
11
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
12
libunity.so
(Missing UUID 0d41af4703121e1f468970d6612837e73cd3add8)
13
libunity.so
(Missing UUID 0d41af4703121e1f468970d6612837e73cd3add8)
14
libunity.so
(Missing UUID 0d41af4703121e1f468970d6612837e73cd3add8)
15
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
16
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
17
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
18
libart.so
(Missing UUID 56e704c544e6c624201be2ab4933e853)
NVentimiglia commented 1 year ago

Hi @jacattrongnlh

This is a confusing bug, and I am not sold that Admob is the cause. That said, I understand it is frustrating and have seen this issue come up from time to time.

Could you try changing the Android API target API Level to 30?

jacattrongnlh commented 1 year ago

I replicated the bug on a build containing nothing but Admob, show an interstitial ad on it and it crashes. I can say with certainty that it's caused by Admob.

I have to target Android 31 to be able to publish on Google Play, do I have to lower the target API to 30 to avoid crashing?

webmonch commented 1 year ago

I also have a ton of similar errors after updating to the last admob on unity.

kunny commented 1 year ago

Since there were no recent activities for this issue, we are therefore reluctantly going to close this bug for now.

If you are still experiencing the problem, please file a new issue with the same description, what happens and system / network tracing / Charles logs.

All system setups can be slightly different, so it's always better to open new issues and reference the related ones. Thanks for your contribution.

jacattrongnlh commented 1 year ago

welp, responsible for thousands of crashes on my app and wontfix. I'll tell everyone to switch to other solutions.