AdMob video-ad in GADBannerView is keep using CPU after a tab-change in UITabBarController

526 Views Asked by At

My setup:

There's a UITabBarController. In the first tab - there's a UINavigationController with a UITableViewController as a root viewcontroller.

In the table of UITableViewController, one of the cells contains a GADBannerView

In the cell with the bannerView, I'm loading the ad like this:

    var bannerView: GADBannerView = GADBannerView()
    ......
    bannerView?.adUnitID = "<my adUnitId>"
    bannerView?.adSize = kGADAdSizeMediumRectangle

    let request = GADRequest()
    request.contentURL = "<my site>"
    bannerView?.load(request)

Problem:

I've noticed, that if the ad contains the video/animation - after switching between tabs - the CPU usage is still high and remains on 15-20% load forever (until you kill the app).

Actual ad looks like this:

enter image description here

A couple observations:

  • if instead of the video-ad - there's a static-image-ad - there's no issue. To me this issue looks like there's some "pause animation" which is not being called for the video-ads.
  • happens on both iOS11 and iOS12
  • func adViewDidReceiveAd(_ bannerView: GADBannerView) is not being called, i.e. the framework knows that the ad is no longer on the screen

This is how processes look like (after switching to another, ad-free tab): enter image description here

Version of the AdMob:

'Firebase/AdMob', '~>5.15.0' (from cocoapods)

Any suggestions are very welcomed.

1

There are 1 best solutions below

0
Patrick_K On

I faced the same problem and solved it by removing the banner every time the ad goes off screen add (re-) add it if it's visible again. This might happen in three cases:

  1. Cell is scrolled out of the visible area. Implemented in:

tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath)

  1. Navigate to subview. Implemented in:

viewWillDisappear

  1. App goes to background Add observer for appDidEnterBackground