Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

ANR with AdMob/Unity Ads in interstitial onAdFailedToLoad

Discussion in 'Unity Ads & User Acquisition' started by Cryofrog, May 28, 2018.

Thread Status:
Not open for further replies.
  1. Cryofrog

    Cryofrog

    Joined:
    Feb 1, 2017
    Posts:
    3
    I asked this on the AdMob SDK group and received a response from someone at Google. He said that it appears I have AdMob (with mediation) integrated properly and suggested I ask here to see if anyone here can help.

    I'm getting a lot of ANRs from com.google.unity.ads.Interstitial$1$1.onAdFailedToLoad in Unity. I have interstitials, rewarded videos, and banner ads, but the only ANRs in an onAdFailedToLoad handler is coming from the interstitials. Unfortunately I can't reproduce it on any of my test devices, and interstitials are showing properly. I tried to create an onAdFailedToLoad by disconnecting from the internet and from connecting to a router that has no Internet connection. I was able to get an onAdFailedToLoad but there was no ANR associated with it. I'm using the second newest Unity AdMob SDK (from April 11th, 2018). There was a newer one but that one had a problem with the banner ads outputing text every frame, which was causing performance problems (which others have reported as well).

    This is the response I got from the AdMob team:

    This is my onAdFailedToLoad in C# I sent them (Unity 2018.1.0f2):

    Code (CSharp):
    1. // Registering handler:
    2. interstitialAd.OnAdFailedToLoad += HandleOnAdFailedToLoad;
    3.  
    4. // Handler:
    5. public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) {
    6. Debug.LogError("HandleFailedToReceiveAd event received with message: " + args.Message);
    7. shown = true;
    8. }
    The shown variable is just a flag, there's no get; set; associated with it, and is used in a later frame. The ANRs are with Android 5.1, 7.0, and 7.1, on a bunch of different devices. This is one of the reports on the Play dashboard:

    "main" prio=5 tid=1 Native
    | group="main" sCount=1 dsCount=0 obj=0x76191770 self=0xef885400
    | sysTid=28298 nice=-4 cgrp=default sched=0/0 handle=0xf2acb534
    | state=S schedstat=( 0 0 0 ) utm=1784 stm=409 core=3 HZ=100
    | stack=0xff6c8000-0xff6ca000 stackSize=8MB
    | held mutexes=
    #00 pc 000000000004a468 /system/lib/libc.so (nanosleep+12)
    #01 pc 000000000024842c /data/app/com.myapp.name-2/lib/arm/libunity.so (???)
    #02 pc 00000000003d4f2c /data/app/com.myapp.name-2/lib/arm/libunity.so (???)
    #03 pc 00000000000087c1 /system/bin/app_process32 (InvokeUserSignalHandler+156)
    #04 pc 000000000014aba3 /system/lib/libart.so (_ZN3art12FaultManager11HandleFaultEiP7siginfoPv+222)
    #05 pc 00000000000171d0 /system/lib/libc.so (???)
    #06 pc 00000000002c04d0 /data/app/com.myapp.name-2/lib/arm/libunity.so (???)
    #07 pc 00000000002bae80 /data/app/com.myapp.name-2/lib/arm/libunity.so (???)
    #08 pc 000000000076d44c /data/app/com.myapp.name-2/lib/arm/libunity.so (???)
    #09 pc 000000000076d3b4 /data/app/com.myapp.name-2/lib/arm/libunity.so (???)
    #10 pc 000000000076d278 /data/app/com.myapp.name-2/lib/arm/libunity.so (???)
    #11 pc 00000000006c48fc /data/app/com.myapp.name-2/lib/arm/libunity.so (???)
    #12 pc 000000000005e011 /data/app/com.myapp.name-2/oat/arm/base.odex (Java_com_unity3d_player_ReflectionHelper_nativeProxyInvoke__ILjava_lang_String_2_3Ljava_lang_Object_2+132)
    at com.unity3d.player.ReflectionHelper.nativeProxyInvoke (Native method)
    at com.unity3d.player.ReflectionHelper.a (unavailable)
    at com.unity3d.player.ReflectionHelper$1.invoke (unavailable)
    at java.lang.reflect.Proxy.invoke (Proxy.java:813)
    at com.google.unity.ads.UnityAdListener.onAdFailedToLoad (UnityAdListener.java)
    at com.google.unity.ads.Interstitial$1$1.onAdFailedToLoad (Interstitial.java:75)
    at com.google.android.gms.internal.zzkh.onAdFailedToLoad (unavailable)
    at com.google.android.gms.internal.zzlj.onTransact (unavailable)
    at android.os.Binder.transact (Binder.java:507)
    at android.os.Handler.handleCallback (Handler.java:751)
    at android.os.Handler.dispatchMessage (Handler.java:95)
    at android.os.Looper.loop (Looper.java:154)
    at android.app.ActivityThread.main (ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke! (Native method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1518)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
     
    Last edited: May 28, 2018
    Simplexws and rearlegmail like this.
  2. digitalmoka

    digitalmoka

    Joined:
    Nov 11, 2016
    Posts:
    7
    I have the same issue.
    Is there anyone who can answer?
     
  3. tinyfishgames

    tinyfishgames

    Joined:
    Dec 11, 2016
    Posts:
    13
  4. digitalmoka

    digitalmoka

    Joined:
    Nov 11, 2016
    Posts:
    7
    Is there someone from the staff who can answer ?

    Thanks for reply
     
  5. vcappa

    vcappa

    Joined:
    Apr 26, 2017
    Posts:
    2
    still no one? Having the same problem
     
  6. yourstoryinteractive

    yourstoryinteractive

    Joined:
    Mar 27, 2017
    Posts:
    49
    We're also seeing an increased number of ANRs. It happened after we upgraded from Unity 2017 to Unity 2018. No idea what to do. Our ANRs are in the bottom zone of the android vitals stats and it looks like we are penalized with less organic traffic.
     
  7. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    Last edited: Oct 27, 2018
  8. Mishaps

    Mishaps

    Joined:
    Nov 28, 2011
    Posts:
    181
    We see most of our ANRs coming from Unity Ads too. Anyone getting ANRs with the new unity monetisation 3.0 sdk?
     
  9. yourstoryinteractive

    yourstoryinteractive

    Joined:
    Mar 27, 2017
    Posts:
    49
    We're getting them with Monetization 3.0 as well as we were getting them with the previous Advertisement module.
     
  10. yourstoryinteractive

    yourstoryinteractive

    Joined:
    Mar 27, 2017
    Posts:
    49
    I was also considering this, but how long will it take for google to see the improvement in vitals and how long will it take for the organic traffic to grow to a level where the removal of Unity Ads will be justified. This is a hard question.
     
  11. Mishaps

    Mishaps

    Joined:
    Nov 28, 2011
    Posts:
    181
    Thanks, good to know it's still happening in the updated plugin. We were considering testing it out.
     
  12. AhmedFarazKnights

    AhmedFarazKnights

    Joined:
    Jul 7, 2018
    Posts:
    5
    Hi
    You can have unity Ads in your game without creating ANRs. I have faced that problem and I used unity ads plugin rather than Unity services and it solved the problem. I think fetching ads from services create some issue that trigger the ANR or crashes.
     
  13. yourstoryinteractive

    yourstoryinteractive

    Joined:
    Mar 27, 2017
    Posts:
    49
    What Unity version do you use?
     
  14. AhmedFarazKnights

    AhmedFarazKnights

    Joined:
    Jul 7, 2018
    Posts:
    5
    I am using unity 2018.1.3 f1
     
    yourstoryinteractive likes this.
  15. Mishaps

    Mishaps

    Joined:
    Nov 28, 2011
    Posts:
    181
    Is that the unity ads plugin on the asset store you are using and it doesn't make ANRs? edit: which version of the unity ads plugin are you using?
     
  16. yourstoryinteractive

    yourstoryinteractive

    Joined:
    Mar 27, 2017
    Posts:
    49
    By the way, are you using the asset store plugin or just enable the ads through the services window?
     
  17. AhmedFarazKnights

    AhmedFarazKnights

    Joined:
    Jul 7, 2018
    Posts:
    5
    We are using 3.0 which is latest in asset store. and ANR don't just come with ad plug-ins there are other reasons also like your FPS, calculating something for so long in main thread. so basically you have to optimize your game to fullest. (Hope this helps you)
     
  18. Sparkline

    Sparkline

    Joined:
    Feb 8, 2013
    Posts:
    118
    I'm facing similar ANR since last app update. Using last version of admob plugin v3.16


    Code (CSharp):
    1. java.lang.Error: FATAL EXCEPTION [Thread-102]
    2. Unity version     : 2018.3.12f1
    3.  
    4. Caused by
    5.  
    6. at com.unity3d.player.ReflectionHelper.nativeProxyInvoke (Native Method)
    7. at com.unity3d.player.ReflectionHelper.a (Unknown Source)
    8. at com.unity3d.player.ReflectionHelper$1.invoke (Unknown Source)
    9. at java.lang.reflect.Proxy.invoke (Proxy.java:813)
    10. at $Proxy9.onAdFailedToLoad (Unknown Source)
    11. at com.google.unity.ads.Interstitial$1$1$2.run (Interstitial.java:89)
    12. at java.lang.Thread.run (Thread.java:762)
     
  19. fiersking_unity

    fiersking_unity

    Joined:
    Oct 3, 2017
    Posts:
    17
    hi !
    same probleme here !
    any solution ?
     
  20. aalexa13

    aalexa13

    Joined:
    Jan 6, 2015
    Posts:
    7
    Hi!
    Had the same problem.
    Try to update Advertisement package to version 3.0.3 (Window -> Package manager)
    This helped me.
     
  21. vfontoura

    vfontoura

    Joined:
    Oct 9, 2014
    Posts:
    40
    Same problem here also
     
  22. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @vfontoura

    Since this original thread is from 2018 and many new updates have come out since then, if you have any problems with Unity Ads and ANRs on Android, please create a new thread and provide as much detail as possible.
     
Thread Status:
Not open for further replies.