App freezes for up to 10 seconds when loading 5 native ads

738 views
Skip to first unread message

Minas Keshishyan

unread,
Oct 28, 2019, 2:11:49 AM10/28/19
to google-adm...@googlegroups.com
We have a code like this to load 5 native ads.


val builder = AdLoader.Builder(context, getString(R.string.main_native))
val adLoader = builder.forUnifiedNativeAd { unifiedNativeAd ->
    nativeAds.add(unifiedNativeAd)
}.withAdListener(object : AdListener() {
   
override fun onAdFailedToLoad(errorCode: Int) {
   
}
}).build()

// Load the Native ads.
adLoader.loadAds(AdRequest.Builder().build(), 5)

I think onUnifiedNativeAdLoaded callback in forUnifiedNativeAd is the culprit, so if we load 2-3 ads instead of 5, app freezes for less time, but still noticeable.

Also I believe that maximum limit of 5 doesn't make sense for apps with feed, other ad network let us load up to 10 ads at least. Eg our feed has 200+ items in feed and we show native ad after every 10 items. So in case of 5 ads people see the same ad over and over again for up to 4 times in a very short period of time, which is very annoying and it negatively affects the revenue.

Mobile Ads SDK Forum Advisor Prod

unread,
Oct 28, 2019, 7:02:50 AM10/28/19
to min...@gmail.com, google-adm...@googlegroups.com
Hi Minas,

Thank you for reaching out to us. Let me do the best I can to assist you in this.

With regard to your concern, would it be possible for you to provide a sample project where the issue is reproducible so we could check it on our end as well? 

On the other hand, I will submit a feature request that will increase the maximum limit of requesting an ad to the engineering team. However, kindly note that there is no guarantee that the said feature will be implemented in a future release. You may keep an eye out on our blog and our Release Notes for any future updates.

Regards,
Teejay Pimentel
Mobile Ads SDK Team

ref:_00D1U1174p._5001UKOe6h:ref

Saida Kasby

unread,
Oct 28, 2019, 7:12:10 AM10/28/19
to Google Mobile Ads SDK Developers
Le lundi 28 octobre 2019 07:11:49 UTC+1, Minas Keshishyan a écrit :
> We have a code like this to load 5 native ads.
>
>
>
>
>

Saida Kasby

unread,
Oct 28, 2019, 7:12:42 AM10/28/19
to Google Mobile Ads SDK Developers
Le lundi 28 octobre 2019 07:11:49 UTC+1, Minas Keshishyan a écrit :
> We have a code like this to load 5 native ads.
>
>
>
>
>

Minas Keshishyan

unread,
Oct 28, 2019, 8:22:43 AM10/28/19
to Google Mobile Ads SDK Developers
Hi Teejay,
I believe the provided code is enough to reproduce the issue.
Just create an app with the latest AdMob SDK, add a single activity and copy paste the code to onCreate.

Mobile Ads SDK Forum Advisor Prod

unread,
Oct 29, 2019, 5:05:36 AM10/29/19
to min...@gmail.com, google-adm...@googlegroups.com
Hi Minas,

I implemented your code to our sample app successfully, and I wasn't able to reproduce the issue on my end.
With this, would you be able to reproduce the issue on our sample app? If so, could you please submit it to us (via Reply Privately to Author option) so we could verify it on our end as well?
Message has been deleted

Minas Keshishyan

unread,
Oct 29, 2019, 6:55:48 AM10/29/19
to Google Mobile Ads SDK Developers
Hi Teejay,
Ok, I just created a sample which reproduces the issue by modifying a sample which loads native ads in feed.
I did some changes to demonstrate the issue. Please download it from here 


To reproduce the issue please run the app and immediately start scrolling the list up and down until ads are loaded. The moment ads are loaded app freezes for couple of seconds ( up to 3 seconds on my Google Pixel and up to 10 seconds on less powerful devices), which produces bunch of ANRs on our production version.
When I reduce NUMBER_OF_ADS to 4 it's a bit faster, when it's just a 2, it's much faster, so I think it got something to do with onUnifiedNativeAdLoaded, every additional ad takes more time.

The hacky workaround to wait until ads are loaded is not a feasible solution as it slows down load time by at least 10 seconds.

Let me know if there are more questions, but please fix it, as right now native ads are not usable in feed where you have to load more than a single ad.

Regards,
Minas

Mobile Ads SDK Forum Advisor Prod

unread,
Oct 30, 2019, 5:00:59 AM10/30/19
to min...@gmail.com, google-adm...@googlegroups.com
Hi Minas,

Thank you for giving an effort in providing detailed information about the issue.

I tried your sample app and monitor its memory through Profilling, and I can see that there is a sudden increase of the memory upon displaying the ads (please see attached screenshot). However, everything comes back to normal once ads have been displayed. With this, I'll raise this to the rest of the team to get more insight and get back to you the soonest they provide their feedback.
Screen Shot 2019-10-30 at 4.19.42 PM.png

Minas Keshishyan

unread,
Oct 30, 2019, 5:50:00 AM10/30/19
to Google Mobile Ads SDK Developers
Hi Teejay,
Interesting findings, I have not done extensive profiling yet, but CPU usage also goes up drastically and the worst thing is that it happens on the main UI thread, so UI freezes for couple of seconds even on powerful devices.

Also I noticed that it got something to do with onUnifiedNativeAdLoaded, so it does something recourse intensive in the UI thread. On the other hand performance for displaying native ad is fine. Try to remove forUnifiedNativeAd code section for builder in loadNativeAds in MainActivity and app will not freeze anymore.

Facebook Audience Network has a slightly different implementation for the same thing. It has something called NativeAdsManager to load native ads. Instead of getting all ads at once in a callback like onUnifiedNativeAdLoaded you can get every next ad by calling NativeAdsManager.nextNativeAd()

I thinks it's a better architecture, but either way onUnifiedNativeAdLoaded should be fixed as it drastically affects app performance and causes app freezes and even ANRs.

Mobile Ads SDK Forum Advisor Prod

unread,
Oct 30, 2019, 6:49:41 AM10/30/19
to min...@gmail.com, google-adm...@googlegroups.com
Hi Minas,

Thank you for sharing your findings.

I'll relay all the information that you mentioned to the rest of the team and get back to you as soon as they provide their feedback.

Romaric Tanguy BANGA

unread,
Nov 13, 2019, 12:47:06 AM11/13/19
to Google Mobile Ads SDK Developers
Hi Minas,
I have also the same problem, have you resolved it ?
Selection_457.png
Message has been deleted

Minas Keshishyan

unread,
Nov 13, 2019, 5:26:46 AM11/13/19
to Google Mobile Ads SDK Developers
Hi Romaric,
Sadly it's not possible to fix on our end. AdMob team is investigating the issue, let's hope they will come up with a resoultion soon!

Minas Keshishyan

unread,
Nov 26, 2019, 1:42:27 AM11/26/19
to Google Mobile Ads SDK Developers
Hi Teejay,
Any news for this one?

Mobile Ads SDK Forum Advisor Prod

unread,
Nov 26, 2019, 4:16:25 AM11/26/19
to min...@gmail.com, google-adm...@googlegroups.com
Hi Minas,

I'm afraid that the issue is still under investigation. Let me follow up this concern to the rest of the team. I'll post an update to this thread once available.

Slava Freelance

unread,
Jul 4, 2020, 3:45:04 PM7/4/20
to Google Mobile Ads SDK Developers
I have same ISSUE like Minas Keshishyan said.
Wtf Google ? Why an app freeze if I download more than 5 ads....
Are you serious ?
I use latest version of AdMob com.google.android.gms:play-services-ads:19.2.0

Mobile Ads SDK Forum Advisor Prod

unread,
Jul 5, 2020, 10:15:12 PM7/5/20
to 4rever...@gmail.com, google-adm...@googlegroups.com

Hi there,

 

Thank you for reaching out to us.

 

The team is still currently investigating this issue. However, do kindly note that all ads are being loaded in the main thread, which should explain why your app (or at least its UI) would experience a slight freeze when loading the native ads. As a workaround, you may want to load as few as only 1 native ad for now if this situation persists.

 

Regards,

Ziv Yves Sanchez

Mobile Ads SDK Team



ref:_00D1U1174p._5004Q21jCZ8:ref
Reply all
Reply to author
Forward
0 new messages