Konstantin Loginov
Konstantin Loginov

Reputation: 16010

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

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:

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.

Upvotes: 2

Views: 576

Answers (1)

Patrick_K
Patrick_K

Reputation: 279

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

Upvotes: 0

Related Questions