Search code examples
androidadmobinterstitial

Why AdMob interstitial lock UI thread?


While using Method Tracing util, I encountered a problem with Android AdMob interstitial ads.

Now I use the latest version of AdMob:

compile 'com.google.firebase:firebase-ads:9.4.0'

And this code:

long start = System.currentTimeMillis();
interstitialAd.loadAd(adRequest);
Log.d(TAG, "load: " + (System.currentTimeMillis() - start) + " ms");

prints:

load: 1250 ms

and locks UI thread.

Example device: LG G3 Android 5.0.

I don't understand why it locks.

P.S. logs

09-08 11:35:52.294 I/Ads: Starting ad request.
09-08 11:35:52.297 I/Ads: Use AdRequest.Builder.addTestDevice("C847646CE34895E5C61DEA64E092F1A5") to get test ads on this device.
09-08 11:35:53.157 W/Ads: The webview is destroyed. Ignoring action.
09-08 11:35:53.224 E/Ads: JS: Uncaught ReferenceError: AFMA_ReceiveMessage is not defined (:1)
09-08 11:35:53.546 I/Ads: Scheduling ad refresh 30000 milliseconds from now.
09-08 11:35:53.553 I/Ads: Ad finished loading.

P.S.2

I look up answer for my question in official AdMob Googe Group Answer


Solution

  • I think this is a bug and should be reported to the Firebase team. I'm looking at the InterstitialAd documentation, and it clearly says for loadAd:

    Start loading the ad on a background thread.

    If it takes such a long time to complete this method, I'm pretty sure that it actually didn't use the background thread or at least didn't do it properly. You can try making this call on a slow network, in which case I think you will get an ANR. That should confirm that this is a blocking call.