SDK 7.5.1: This application is modifying the autolayout engine from a background thread

631 views
Skip to first unread message

Johannes Plunien

unread,
Oct 6, 2015, 4:37:29 AM10/6/15
to Google Mobile Ads SDK Developers
Hi,

we're using GoogleMobileAdsSdkiOS 7.5.1 via CocoaPods on our application [1]. We have fairly standard setup with a UICollectionView and some UICollectionViewCell objects. In the cell objects we ad a GADSearchBannerView as a subview to the cell's contentView. We also set and implement the GADBannerViewDelegate. When we start scrolling and new ad cells are being used, we start seeing following warnings in the console.log of Xcode [2]. As soon as we comment out this line, the warning goes away:

    GADRequest *request = [self buildRequest];

    [self.bannerView loadRequest:request];


We checked already the implementations of the GADBannerViewDelegate methods, all of them are coming back on the main thread. All other methods inside our cell are also called on the main thread. So we're blind there and rely on you guys, can you please have a look into it?


Thanks,
Johannes


Vu Chau (MobileAds SDK Team)

unread,
Oct 6, 2015, 4:32:22 PM10/6/15
to Google Mobile Ads SDK Developers
Hi Johannes,

When I ran your live app here on our device, I wasn't able to get the reported warning.  Is there any chance you can send us some code snippets that reproduce this warning locally?

Thanks!

Vu Chau
Mobile Ads SDK Team

Johannes Plunien

unread,
Oct 7, 2015, 2:03:13 AM10/7/15
to Google Mobile Ads SDK Developers
Hey,

thanks for your quick response. Here's a minimal example reproducing the issue.

2. open AdMob.xcworkspace
3. CMD + r
4. scroll a few screens down
5. notice warnings in Xcode console: "This application is modifying the autolayout engine from a background thread......."

If you need more information, please let me know. Also if we are doing something wrong in the example code I provided, also please let me know.

Thanks,
Johannes

Johannes Plunien

unread,
Oct 7, 2015, 2:07:05 AM10/7/15
to Google Mobile Ads SDK Developers
Sorry, I missed giving one important testing hint: Run on iOS 9 :).

Jason McNeil

unread,
Oct 7, 2015, 10:57:34 AM10/7/15
to Google Mobile Ads SDK Developers
There are many issues with admob doing layout while not running on the main thread.

It's a common but not consistent bug. We get about 1% to 2% of users with this bug daily.

Vu Chau (MobileAds SDK Team)

unread,
Oct 7, 2015, 2:59:10 PM10/7/15
to Google Mobile Ads SDK Developers
Hi guys,

Thanks for the code.  I was able to reproduce the warning exactly as you reported.  It looks like the exception comes from a WebThread, so there might be some operations on a WebView from a background thread.  I'll speak with the rest of the team about this and see what we can do to rectify the issue.

Thanks,

Vu Chau
Mobile Ads SDK Team

Tristan Emrich

unread,
Oct 7, 2015, 3:52:04 PM10/7/15
to Google Mobile Ads SDK Developers
In your CollectionViewController.m file, try putting [cell setUpAd] in a background thread to avoid blocking the main thread (which is probably causing the warning):

dispatch_async(dispatch_get_main_queue(), ^{

        [cell setUpAd];

});


Let me know if you have any additional questions or issues.

Thank you!
Tristan

Johannes Plunien

unread,
Oct 7, 2015, 4:04:35 PM10/7/15
to google-adm...@googlegroups.com
Hi,

thanks for your response. It does fix the warning. However I find this solution a bit disturbing. I have also changed your recommendation slightly:


This points out that there is something weird going on when creating a GADSearchBannerView object.

So I'd really like to see this fix *inside* your SDK, please. A consumer of your API should not have to worry about this, right?

Thanks,
Johannes

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/_Pk6b8uQ7cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.
To post to this group, send email to google-adm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Johannes Plunien | Friedbergstr. 30, 14057 Berlin | +49-151-68969263

Tristan Emrich

unread,
Oct 7, 2015, 5:28:40 PM10/7/15
to Google Mobile Ads SDK Developers
Hi Johannes,

Taking a closer look at your example, it appears you are creating a GADSearchBannerView and a GADSearchRequest every time setUpAd is called. You should only need to create each of them once. Attached a modified version of your AdCollectionViewCell implementation.

Let me know if that helps.

Thank you!
Tristan


On Wednesday, October 7, 2015 at 1:04:35 PM UTC-7, Johannes Plunien wrote:
Hi,

thanks for your response. It does fix the warning. However I find this solution a bit disturbing. I have also changed your recommendation slightly:


This points out that there is something weird going on when creating a GADSearchBannerView object.

So I'd really like to see this fix *inside* your SDK, please. A consumer of your API should not have to worry about this, right?

Thanks,
Johannes
On 7 October 2015 at 21:52, Tristan Emrich <mobileadssdk-advisor+tristan@google.com> wrote:
In your CollectionViewController.m file, try putting [cell setUpAd] in a background thread to avoid blocking the main thread (which is probably causing the warning):

dispatch_async(dispatch_get_main_queue(), ^{

        [cell setUpAd];

});


Let me know if you have any additional questions or issues.

Thank you!
Tristan

On Wednesday, October 7, 2015 at 11:59:10 AM UTC-7, Vu Chau (MobileAds SDK Team) wrote:
Hi guys,

Thanks for the code.  I was able to reproduce the warning exactly as you reported.  It looks like the exception comes from a WebThread, so there might be some operations on a WebView from a background thread.  I'll speak with the rest of the team about this and see what we can do to rectify the issue.

Thanks,

Vu Chau
Mobile Ads SDK Team

On Wednesday, October 7, 2015 at 10:57:34 AM UTC-4, Jason McNeil wrote:
There are many issues with admob doing layout while not running on the main thread.

It's a common but not consistent bug. We get about 1% to 2% of users with this bug daily.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/_Pk6b8uQ7cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
AdCollectionViewCell.m

Johannes Plunien

unread,
Oct 12, 2015, 9:14:10 AM10/12/15
to Google Mobile Ads SDK Developers
Hey Tristan,

thanks for your suggestion. This would mean, that every dequeued ad cell would display the same ad, right? What we want is: Every n-th cell should be an ad cell. Every of these ad cells should display a new/different ad. But it feels a little like this wish is working against your design :).

Cheers,
Johannes

On Wednesday, October 7, 2015 at 11:28:40 PM UTC+2, Tristan Emrich wrote:
Hi Johannes,

Taking a closer look at your example, it appears you are creating a GADSearchBannerView and a GADSearchRequest every time setUpAd is called. You should only need to create each of them once. Attached a modified version of your AdCollectionViewCell implementation.

Let me know if that helps.

Thank you!
Tristan

On Wednesday, October 7, 2015 at 1:04:35 PM UTC-7, Johannes Plunien wrote:
Hi,

thanks for your response. It does fix the warning. However I find this solution a bit disturbing. I have also changed your recommendation slightly:


This points out that there is something weird going on when creating a GADSearchBannerView object.

So I'd really like to see this fix *inside* your SDK, please. A consumer of your API should not have to worry about this, right?

Thanks,
Johannes
On 7 October 2015 at 21:52, Tristan Emrich <mobileadssdk-a...@google.com> wrote:
In your CollectionViewController.m file, try putting [cell setUpAd] in a background thread to avoid blocking the main thread (which is probably causing the warning):

dispatch_async(dispatch_get_main_queue(), ^{

        [cell setUpAd];

});


Let me know if you have any additional questions or issues.

Thank you!
Tristan

On Wednesday, October 7, 2015 at 11:59:10 AM UTC-7, Vu Chau (MobileAds SDK Team) wrote:
Hi guys,

Thanks for the code.  I was able to reproduce the warning exactly as you reported.  It looks like the exception comes from a WebThread, so there might be some operations on a WebView from a background thread.  I'll speak with the rest of the team about this and see what we can do to rectify the issue.

Thanks,

Vu Chau
Mobile Ads SDK Team

On Wednesday, October 7, 2015 at 10:57:34 AM UTC-4, Jason McNeil wrote:
There are many issues with admob doing layout while not running on the main thread.

It's a common but not consistent bug. We get about 1% to 2% of users with this bug daily.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/_Pk6b8uQ7cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-adm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tristan Emrich

unread,
Oct 12, 2015, 12:59:20 PM10/12/15
to Google Mobile Ads SDK Developers
Hi Johannes,
If you would like a new add every nth cell, then you can pull out the [self loadRequest] from the !self.bannerView "if" statement in AdCollectionViewCell. This will make a new ad request for every nth cell.  

If your app is an AdMob implementation, then please make sure that it adheres to the banner implementation policies

Thank you!
Tristan

Otam

unread,
Oct 23, 2015, 2:27:52 AM10/23/15
to Google Mobile Ads SDK Developers
I'm getting the same error under version 7.5.2, iPhone6+, ios 9.0. It only disappear if i downgrade all the way to 7.4.1.

As Vu Chau mentioned the problem is indeed in  WebThread and since 7.5.2 didn't solve this i'm assuming this is still an open issue?


Tristan Emrich

unread,
Oct 23, 2015, 11:30:52 AM10/23/15
to Google Mobile Ads SDK Developers
Hi,

Can you please provide a sample app that reproduces this issue? This will make it easier to debug and will help us determine what is causing this error.

Thank you!
Tristan
Reply all
Reply to author
Forward
Message has been deleted
0 new messages