Android Mopub 5.4.0 ANR


#1

Hi.
MoPub SDK 5.4 generates ANR errors - fine in 5.3 without any other app code changes.
SDK initilization is done properly.

getRequestQueue() is called in two threads while it is being synchronized.

“main” prio=5 tid=1 Blocked
| group=“main” sCount=1 dsCount=0 obj=0x748008b0 self=0x7f93640a00
| sysTid=19536 nice=0 cgrp=default sched=0/0 handle=0x7f974e9a98
| state=S schedstat=( 867098798 46070312 654 ) utm=74 stm=12 core=1 HZ=100
| stack=0x7fe9660000-0x7fe9662000 stackSize=8MB
| held mutexes=
at com.mopub.network.Networking.getRequestQueue (SourceFile:69)

  • waiting to lock <0x01a9b16f> (a java.lang.Class<com.mopub.network.Networking>) held by thread 31
    at com.mopub.network.AdLoader.a (SourceFile:255)
    at com.mopub.network.AdLoader.loadNextAd (SourceFile:154)
  • locked <0x042a8e7c> (a java.lang.Object)
    at com.mopub.mobileads.AdViewController.b (SourceFile:519)
    at com.mopub.mobileads.AdViewController.a (SourceFile:270)
    at com.mopub.mobileads.AdViewController.f (SourceFile:250)
    at com.mopub.mobileads.AdViewController.loadAd (SourceFile:232)
    at com.mopub.mobileads.MoPubView.loadAd (SourceFile:108)
    at com.xxxxxx.a.b.e.d (SourceFile:104)
    at com.xxxxxx.a.b.a.e (SourceFile:152)
    at com.xxxxxx.a.b.c.c (SourceFile:158)
    at com.xxxxxx.a.b.c.a (SourceFile:37)
    at com.xxxxxx.a.b$1.onInitializationFinished (SourceFile:47)
  • locked <0x0d70a305> (a java.util.ArrayList)
    at com.mopub.common.MoPub$1.run (SourceFile:322)
    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:6144)
    at java.lang.reflect.Method.invoke! (Native method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)

“AsyncTask #2” prio=5 tid=31 Waiting
| group=“main” sCount=1 dsCount=0 obj=0x12c1a160 self=0x7f6b325a00
| sysTid=19822 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0x7f6a873450
| state=S schedstat=( 121453707 25078639 263 ) utm=9 stm=3 core=1 HZ=100
| stack=0x7f6a771000-0x7f6a773000 stackSize=1037KB
| held mutexes=
at java.lang.Object.wait! (Native method)

  • waiting on <0x0a87577b> (a java.lang.Object)
    at xk.b (SourceFile:173)
    at xk.d (SourceFile:186)
  • locked <0x0a87577b> (a java.lang.Object)
    at com.android.webview.chromium.WebViewChromiumFactoryProvider.getStatics (SourceFile:204)
  • locked <0x0a87577b> (a java.lang.Object)
    at android.webkit.WebSettings.getDefaultUserAgent (WebSettings.java:1246)
    at com.mopub.network.Networking.getUserAgent (SourceFile:149)
  • locked <0x01a9b16f> (a java.lang.Class<com.mopub.network.Networking>)
    at com.mopub.network.Networking.getRequestQueue (SourceFile:75)
  • locked <0x01a9b16f> (a java.lang.Class<com.mopub.network.Networking>)
    at com.mopub.network.TrackingRequest.makeTrackingHttpRequest (SourceFile:110)
    at com.mopub.network.TrackingRequest.makeTrackingHttpRequest (SourceFile:148)
    at com.mopub.mobileads.MoPubConversionTracker.reportAppOpen (SourceFile:86)
    at com.mopub.common.privacy.PersonalInfoManager$5.onInitializationFinished (SourceFile:566)
    at com.mopub.common.privacy.MoPubIdentifier.a (SourceFile:221)
    at com.mopub.common.privacy.MoPubIdentifier.a (SourceFile:201)
    at com.mopub.common.privacy.MoPubIdentifier.a (SourceFile:188)
    at com.mopub.common.privacy.MoPubIdentifier$a.doInBackground (SourceFile:2105)
    at android.os.AsyncTask$2.call (AsyncTask.java:305)
    at java.util.concurrent.FutureTask.run (FutureTask.java:237)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
    at java.lang.Thread.run (Thread.java:761)

#2

Also facing this issue after updating mopub sdk to latest version 5.4.0. Its occurring at the time of ad load call


#3

I have reverted to 5.3.0 and no more ANR errors - no other changes made. Simply revert from 5.4.0 to 5.3.0.


#4

Hi,

Thanks for reporting this.

While we released a fix in the 5.4.0 Android SDK version that helped mitigate the ANR (Application Not Responding), it seems there is another door causing ANRs in 5.4.

Our engineering team is currently investigating it and we hope to a fix soon.

If you any other questions, feel free to reach out to support@mopub.com.

Thanks!


#5

me too.


#6

I didn’t even notice ANRs on 5.3 but I am having many ANR report with MoPub 5.4


#7

I’m having this issue too. Since updating to 5.4.1 I’ve seen a huge increase in ANR (Application not responding) issues in my app, 3% of sessions are affected by the app freezing :frowning:

How is the fix progressing?

Thanks


#8

@rmayayo, we believe we’ve identified a fix for that ANR, and are shipping that fix in the next SDK release. Hold tight!

In the meantime, publishers can add a call to Networking.getRequestQueue(Context) right before making the call to MoPub.initializeSdk([args]) to alleviate what we believe to be the issue.


#9

We use 5.2.0 in Unity, and see the exact same ANRs. Oddly, we’ve been using the same SDK for the past 2 months, and we suddenly saw a surge in the ANRs over the Dec 29th weekend.
Can you share light on what conditions cause the ANR?


#10

Thanks for letting us know! Our SDK engineering team has shared a detailed explanation of the cause here. Look for this fix in the upcoming SDK release!


#11

So, is the recommendation to do both :

  1. Add delayed timer after initialization request is done
    AND

  2. add a call to Networking.getRequestQueue(Context)


#12

@khambadkone, since you’re on Unity, there’s no way to call the Android method Networking.getRequestQueue(Context) from C#, so our recommendation would be to add the delay after initialization and before the ad request. This approach is not as foolproof so there might still be remaining ANR instances until the permanent fix in the upcoming MoPub Android SDK release.


#13

We call getRequestQueue using unity’s AndroidJavaClass helper. Would that suffice?


#14

That will do!


#15

Here is a repository you can run to reproduce the issue consistently. https://github.com/brendanw/mopubANR


#16

@chauduyphanvu We tried adding a 1 second delay between sdk initialization and the first ad load in production, and are still getting slaughtered by this ANR. From my own testing, I can sometimes reproduce even with a 2 second delay, but less often. The problem with increasing the delay is it reduces impressions. This bug means less money for mopub and the publisher.


#17

Thanks for letting us know! There are two workarounds provided on this thread - did you try the other one? Publishes can add a call to Networking.getRequestQueue(Context) right before making the call to MoPub.initializeSdk([args]) to alleviate what we believe to be the issue.

A new SDK is scheduled to be released later this month that contains the official fix. Make sure to watch for that and update!


#18

@chauduyphanvu For the sample project, adding Networking#getRequestQueue before the initializeSdk call prevents the ANR from being 100% replicable.

The wording earlier was that adding that call before initializeSdk would “alleviate” the bug, so I think for our next release we are leaning towards just downgrading to 5.3 or 5.2 (we were on 5.2 before).