Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Alarming crash on Android using Unity 2019.3.7f1 ( GetParamCount )

Discussion in 'Android' started by a-tauzzi, Apr 18, 2020.

  1. a-tauzzi

    a-tauzzi

    Joined:
    Dec 20, 2015
    Posts:
    33
    Just a few days ago I updated my app on Google Play that I compiled with Unity 2019.3.7f1
    I also updated GoogleMobileAds updating it to version 5.0.1

    Before I was using Unity version 2019.2.16f1 and GoogleMobileAds was version lower than 5.0.1 and I didn't experience these types of crashes.

    I'm getting a lot of crashes mainly:

    -------------------------------------------------
    FIRST ONE (arm): 128 crashes affecting 99 users

    ???
    libil2cpp.0x228408 (SIGSEGV)


    Happening on many different phones.

    arm-linux-androideabi-addr2line -f -C -e libil2cpp.sym.so 0x228408
    il2cpp::vm::Method::GetParamCount(MethodInfo const*)
    --------------------------------------------------
    SECOND ONE (arm64-v8a): 68 crashes affecting 48 users (many huawei)


    libil2cpp.0x58fd34 (il2cpp::vm::Method::GetParamCount(MethodInfo const*))
    libunity.0x2e15e0 (scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool))
    libunity.0x2eda30 (ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool))
    libunity.0x164bd4 (UnityJavaProxy_invoke
    (_JNIEnv*, _jobject*, long, _jstring*, _jobjectArray*))
    base.0x95cbcc
     
  2. Sailendu

    Sailendu

    Joined:
    Jul 23, 2009
    Posts:
    250
    I am also getting so many of similar crashes from Google Play Android vitals, none of my devices produces such crash, and these reports are almost impossible to understand. Did you find any solution? Please let me know.
     
    a-tauzzi likes this.
  3. a-tauzzi

    a-tauzzi

    Joined:
    Dec 20, 2015
    Posts:
    33
    No clue till now! Unfortunately it seems other people not having similar problems.
     
  4. ARPAplus

    ARPAplus

    Joined:
    Jun 5, 2015
    Posts:
    32
    A lot of similar crashes on the latest 2019.2.
     
  5. nztree

    nztree

    Joined:
    Oct 16, 2016
    Posts:
    9
    Are the crashes on Android 4? If so, there's a good chance they're crashing due to optimized frame pacing being turned on. It actually crashed openGL on our testing devices (after we received a flood of crash reports) so badly that the engine wouldn't render whatsoever.
     
  6. e2000

    e2000

    Joined:
    Sep 10, 2016
    Posts:
    7
    Similar issue with Unity 2019.4.1 and GoogleMobileAds 5.2.0.
    I can't reproduce the issue by myself but there are lots of crashes in Crash Report Services like Crashlytics.
    Removing AdMob by now and will use it in an ad mediation service.
     
  7. a-tauzzi

    a-tauzzi

    Joined:
    Dec 20, 2015
    Posts:
    33
    Are you calling AdMob API in coroutines? That was the problem I met. After removing AdMob API calls from coroutines, number of crashes went down.
     
  8. e2000

    e2000

    Joined:
    Sep 10, 2016
    Posts:
    7
    No, I did not use coroutines for calling AdMob API. My implementation is just like their sample codes.

    First, init AdMob in the Start method:

    Code (CSharp):
    1. // Initialize the Google Mobile Ads SDK.
    2.         MobileAds.Initialize(initStatus => { });
    Rest of the related code:

    Code (CSharp):
    1. public RewardedAd CreateAndLoadRewardedAd(string adUnitId)
    2.     {
    3.         RewardedAd rewardedAd = new RewardedAd(adUnitId);
    4.  
    5.         // Called when an ad request has successfully loaded.
    6.         rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
    7.         // Called when an ad request failed to load.
    8.         //rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
    9.         // Called when an ad is shown.
    10.         rewardedAd.OnAdOpening += HandleRewardedAdOpening;
    11.         // Called when an ad request failed to show.
    12.         rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
    13.         // Called when the user should be rewarded for interacting with the ad.
    14.         rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
    15.         // Called when the ad is closed.
    16.         rewardedAd.OnAdClosed += HandleRewardedAdClosed;
    17.  
    18.         // Create an empty ad request.
    19.         AdRequest request = new AdRequest.Builder().Build();
    20.         // Load the rewarded ad with the request.
    21.         rewardedAd.LoadAd(request);
    22.         return rewardedAd;
    23.     }
    24.  
    25.     public void ShowAd()
    26.     {
    27.         if (rewardedAd != null && rewardedAd.IsLoaded())
    28.         {
    29.             rewardedAd.Show();
    30.         }
    31.     }
    32.  
    33.     public void LoadAd(string zoneName)
    34.     {
    35.         if (rewardedAd == null || !rewardedAd.IsLoaded()))
    36.         {
    37.             rewardedAd = CreateAndLoadRewardedAd(zoneName);
    38.         }
    39.     }
    40.  
    41.     public void HandleRewardedAdLoaded(object sender, EventArgs args)
    42.     {
    43.         print("ADMOB HandleRewardedAdLoaded event received");
    44.     }
    45.  
    46.     public void HandleRewardedAdFailedToLoad(object sender, AdErrorEventArgs args)
    47.     {
    48.         print("ADMOB HandleRewardedAdFailedToLoad event received with message: " + args.Message);
    49.     }
    50.  
    51.     public void HandleRewardedAdOpening(object sender, EventArgs args)
    52.     {
    53.         print("ADMOB HandleRewardedAdOpening event received");
    54.     }
    55.  
    56.     public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
    57.     {
    58.         print("ADMOB HandleRewardedAdFailedToShow event received with message: " + args.Message);
    59.     }
    60.  
    61.     public void HandleRewardedAdClosed(object sender, EventArgs args)
    62.     {
    63.         print("ADMOB HandleRewardedAdClosed event received");
    64.     }
    65.  
    66.     public void HandleUserEarnedReward(object sender, Reward args)
    67.     {
    68.         string type = args.Type;
    69.         double amount = args.Amount;
    70.         print("ADMOB HandleRewardedAdRewarded event received for " + amount.ToString() + " " + type);
    71.     }
     
  9. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    I believe you have the same issue I did, nowhere I noticed on Google documentation that their events would fire on a separate thread, but only on their sample file:

    https://github.com/googleads/google...World/Assets/Scripts/GoogleAdMobController.cs

    Use that MobileAdsEventExecutor on your event handlers...


    Code (CSharp):
    1. private void HandleInitCompleteAction(InitializationStatus initstatus)
    2.     {
    3.         // Callbacks from GoogleMobileAds are not guaranteed to be called on
    4.         // main thread.
    5.         // In this example we use MobileAdsEventExecutor to schedule these calls on
    6.         // the next Update() loop.
    7.         MobileAdsEventExecutor.ExecuteInUpdate(() => {
    8.             statusText.text = "Initialization complete";
    9.             RequestBannerAd();
    10.         });
    11.     }
    12.  
     
    Fraccas, roointan and e2000 like this.
  10. y0rshl

    y0rshl

    Joined:
    Jul 12, 2013
    Posts:
    20
    Hi @JustAnotherDude! Are you using MobileAdsEventExecutor to run code just for the initialization or all callbacks such as

    rewardedAd.OnAdLoaded
    rewardedAd.OnAdFailedToLoad
    rewardedAd.OnUserEarnedReward
    etc
     
  11. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    All callbacks.
     
    y0rshl likes this.
  12. y0rshl

    y0rshl

    Joined:
    Jul 12, 2013
    Posts:
    20
    Thanks!
     
    okany likes this.
  13. Sigma_App_Labs

    Sigma_App_Labs

    Joined:
    Feb 6, 2018
    Posts:
    2
    Is this issue fixed ? Please help.
     
  14. y0rshl

    y0rshl

    Joined:
    Jul 12, 2013
    Posts:
    20
    Use MobileAdsEventExecutor to run code on all callbacks.
     
  15. Shefich

    Shefich

    Joined:
    May 23, 2013
    Posts:
    107
    i still have too many such crashes:

    Code (CSharp):
    1. Crashed: Thread: SIGSEGV  0x000000000000002a
    2. #00 pc 0x1e9834 libil2cpp.so (il2cpp::vm::Method::GetParamCount(MethodInfo const*) [Method.cpp:82]) (BuildId: ce8e306c3d9f2e026442d386b59776abae790184)
    3. #01 pc 0xa032ba libunity.so (__ashldi3) (BuildId: 043a2af72b5f34248fa80a526d4113b6f595912b)
    4. #02 pc 0x1b7103 libunity.so (ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)) (BuildId: 043a2af72b5f34248fa80a526d4113b6f595912b)
    5. #03 pc 0xd1553 libunity.so (UnityJavaProxy_invoke(_JNIEnv*, _jobject*, long long, _jstring*, _jobjectArray*)) (BuildId: 043a2af72b5f34248fa80a526d4113b6f595912b)
    I added MobileAdsEventExecutor to the all callbacks.
    Also I added "GoogleMobileAds.Api.MobileAds.RaiseAdEventsOnUnityMainThread = true;"
    Nothing helps.

    Unity 2021. 3.26, 2020.3.48
    Admob 8.2.0
    OneSignal 3.0.10
    Firebase 11.0.0
     
  16. Shefich

    Shefich

    Joined:
    May 23, 2013
    Posts:
    107
    Which version of gradle are you guys using?
    Also which dependencies are used in mainTemplate.gradle?

    Code (CSharp):
    1. dependencies {
    2.         classpath 'com.android.tools.build:gradle:4.0.1'
    3.         classpath 'com.guardsquare:proguard-gradle:7.1.0'
    4.         classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.3, 0.99.99]'
    5. **BUILD_SCRIPT_DEPS**}
     
  17. dendyak

    dendyak

    Joined:
    Mar 7, 2015
    Posts:
    18
    You need to use MobileAdsEventExecutor in every callback, even on Initiate.

    Code (CSharp):
    1. public void Initiate() {
    2.             MobileAds.RaiseAdEventsOnUnityMainThread = true;
    3.             MobileAds.Initialize(HandleInitCompleteAction);
    4. }
    5. private void HandleInitCompleteAction(InitializationStatus initstatus) {
    6.             MobileAdsEventExecutor.ExecuteInUpdate(() => {
    7.                 //do something
    8.             });
    9. }