AdMob native AD lag

Viewed 609

I have a NativeContentAdView in a ListView item. When I call setNativeAd(NativeAd) on it, a noticeable lag happens. All AdMob class and method names are mangled (zzdt, zzalp, zzow etc) so I omit them.

Things AdMob performs in View#onAttachedToWindow callback:

  • registers several BroadcastReceivers (each requires a Binder transaction) (sum ~10 ms)

Things AdMob performs in OnScrollChangedListener#onScrollChanged:

  • dozens of DP-to-PX conversions, calling Display#getMetrics and triggering a Binder transaction for each conversion (sum ~7 ms)

  • generates some JSON (~8 ms)

  • evaluates some JS (~7 ms)

  • creates a WebView instance (~5.5 ms), sets it up (~9 ms), asks it to loadUrl (~7.5 ms)

Inside Handler#handleCallbacks (i. e. Handler#post):

  • Creates a WebView, sets it up, adds to Window and evaluates JS (~27 ms)

  • Gets packageInfo (IPC), creates a WebView, sets it up, asks to loadUrl, checks permissions (IPC), parses JSON, gets packageInfo one more time, introspects resources via Resources#getIdentifier, gets activityInfo (IPC) (sum ~40 ms)

Obviously, all these heavyweight operations are leading to jerky scroll.

What should I do to avoid lags or what I'm possibly doing wrong? Why don't AdMob native AD is as slow in other applications I've seen?

Using AdMob/GMS v. 10 and/or 11, but 16 shows the same lags. All measurements are taken with Nanoscope on their special emulator, but lag on a real not-so-old Nexus 5 is even worse.

0 Answers
Related