UIWebView vs WKWebView and app freezes

1,780 views
Skip to first unread message

Johannes Plunien

unread,
May 3, 2017, 5:32:39 AM5/3/17
to Google Mobile Ads SDK Developers
Dear Google Mobile Ads SDK Developers,

from time to time we see our app (eBay Kleinanzeigen) freeze entirely. When debugging the issue we can see a deadlock caused by UIWebView. We have already filed a Radar for this [1]. We have only little hope that Apple will do something about it, because there is already a successor of UIWebView: WKWebView. You can assume that UIWebView will get deprecated in any of the coming iOS versions, and therefore will receive less attention and bug fixing on Apple's side.

The example code [2] that we attached to the Radar is obviously using UIWebView, to trigger the deadlock. But when doing a few changes to use WKWebView instead of UIWebView, the deadlock does not happen anymore. This is good news!

Is it possible to migrate Google-Mobile-Ads-SDK to use WKWebView instead of UIWebView to avoid this deadlock? This would be really great! We understand that you're still supporting iOS 6, but maybe you can add a switch for iOS 8+ to use WKWebView?

Thanks,
Johannes

Deepika Uragayala- MobileAds SDK team

unread,
May 3, 2017, 1:49:06 PM5/3/17
to Google Mobile Ads SDK Developers
Hi Johannes,

MobileAds SDK already uses WKWebView. So, do let us know if you ever have similar issues when using our SDK and we would have a look into it.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

Johannes Plunien

unread,
May 3, 2017, 9:54:50 PM5/3/17
to Google Mobile Ads SDK Developers
Hi Deepika,

in our current version of the application I have tried to verify this, but it does not seem to be true. Here are my findings:

We are using your SDK via CocoaPods:

Google-Mobile-Ads-SDK (7.19.1)

I have set some regular expression breakpoints via LLDB:

br s -r WKWebView\ init.*
br s -r UIWebVIew\ init.*

When I run our application and visit some screen that displays ads, I can only see breakpoints in UIWebView firing.

Here's a stack trace and the list of breakpoints:

(lldb) bt

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.6

  * frame #0: 0x000000010f40a3ea UIKit`-[UIWebView initWithFrame:]

    frame #1: 0x0000000109adff1a Kleinanzeigen`___lldb_unnamed_symbol5744$$Kleinanzeigen + 205

    frame #2: 0x0000000109ae90cb Kleinanzeigen`___lldb_unnamed_symbol5925$$Kleinanzeigen + 383

    frame #3: 0x0000000109ae9418 Kleinanzeigen`___lldb_unnamed_symbol5927$$Kleinanzeigen + 107

    frame #4: 0x0000000109a796fe Kleinanzeigen`___lldb_unnamed_symbol3010$$Kleinanzeigen + 174

    frame #5: 0x0000000109a74a76 Kleinanzeigen`___lldb_unnamed_symbol2873$$Kleinanzeigen + 168

    frame #6: 0x0000000109a74ce4 Kleinanzeigen`___lldb_unnamed_symbol2874$$Kleinanzeigen + 128

    frame #7: 0x0000000109a74e89 Kleinanzeigen`___lldb_unnamed_symbol2878$$Kleinanzeigen + 89

    frame #8: 0x0000000109922cc5 Kleinanzeigen`@nonobjc DFPBannerView.init(adSize : GADAdSize) -> DFPBannerView at EBKVIPBannerPresenter.swift:0


(lldb) br list

Current breakpoints:

1: regex = 'WKWebView initWithFrame', locations = 4, resolved = 2, hit count = 0

  1.1: where = WebKit`-[WKWebView initWithFrame:], address = 0x000000010ebea9da, resolved, hit count = 0 

  1.2: where = WebKit`-[WKWebView initWithFrame:configuration:], address = 0x000000010ebec34b, resolved, hit count = 0 


2: regex = 'UIWebView init', locations = 7, resolved = 7, hit count = 9

  2.1: where = UIKit`+[UIWebView initialize], address = 0x000000010f408aa6, resolved, hit count = 0 

  2.2: where = UIKit`-[UIWebView initWithFrame:], address = 0x000000010f40a3ea, resolved, hit count = 9 

  2.3: where = UIKit`-[UIWebView initWithCoder:], address = 0x000000010f40a461, resolved, hit count = 0 


Is there something we need to do to make the SDK use WKWebView instead of UIWebView?

Thanks,
Johannes

Deepika Uragayala- MobileAds SDK team

unread,
May 4, 2017, 11:23:53 AM5/4/17
to Google Mobile Ads SDK Developers
Hi Johannes,

There is nothing you need to do to enable WKWebView as this is already done for you. I would not be able to comment on any internal workings of SDK.

Regards,
Deepika Uragayala
Mobile Ads SDK Team


Johannes Plunien

unread,
May 4, 2017, 10:02:21 PM5/4/17
to google-adm...@googlegroups.com
Hi,

but given my information it does not look like it is using WKWebView. Don't you agree? Have a look at the call stack.

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/R1-yLiAjPyQ/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.
--
Sent from Gmail Mobile

Deepika Uragayala- MobileAds SDK team

unread,
May 5, 2017, 12:59:11 PM5/5/17
to Google Mobile Ads SDK Developers
Hi Johannes,

We use WKWebView under the hood and other than that, I would not be able to comment on any internal workings of the SDK.

Regards,
Deepika Uragayala
Mobile Ads SDK Team


On Thursday, May 4, 2017 at 10:02:21 PM UTC-4, Johannes Plunien wrote:
Hi,

but given my information it does not look like it is using WKWebView. Don't you agree? Have a look at the call stack.

Johannes

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.

Johannes Plunien

unread,
May 5, 2017, 9:43:09 PM5/5/17
to google-adm...@googlegroups.com
This was very unhelpful so far. I didn't even get the feeling that you had a look at this:

  * frame #0: 0x000000010f40a3ea UIKit`-[UIWebView initWithFrame:]

    frame #8: 0x0000000109922cc5 Kleinanzeigen`@nonobjc DFPBannerView.init(adSize : GADAdSize) -> DFPBannerView at EBKVIPBannerPresenter.swift:0

This clearly proves that the SDK is still using UIWebView, which is causing issues in our app.

On Fri 5. May 2017 at 20:59, 'Deepika Uragayala- MobileAds SDK team' via Google Mobile Ads SDK Developers <google-adm...@googlegroups.com> wrote:
Hi Johannes,

We use WKWebView under the hood and other than that, I would not be able to comment on any internal workings of the SDK.

Regards,
Deepika Uragayala
Mobile Ads SDK Team


On Thursday, May 4, 2017 at 10:02:21 PM UTC-4, Johannes Plunien wrote:
Hi,

but given my information it does not look like it is using WKWebView. Don't you agree? Have a look at the call stack.

Johannes

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.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/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.

Deepika Uragayala- MobileAds SDK team

unread,
May 8, 2017, 3:37:20 PM5/8/17
to Google Mobile Ads SDK Developers
Hi Johannes,

If you want WKWebView to be persistent throughout your application, then you would have to set the following in your inflo.plist file: 

Key: gad_preferred_webview 
Value: wkwebview 

This would override the defaults and the SDK would only load WKWebView. However, note that this is still an experiment and do let us know if you are facing any issues with regards to this.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

On Friday, May 5, 2017 at 9:43:09 PM UTC-4, Johannes Plunien wrote:
This was very unhelpful so far. I didn't even get the feeling that you had a look at this:

  * frame #0: 0x000000010f40a3ea UIKit`-[UIWebView initWithFrame:]

    frame #8: 0x0000000109922cc5 Kleinanzeigen`@nonobjc DFPBannerView.init(adSize : GADAdSize) -> DFPBannerView at EBKVIPBannerPresenter.swift:0

This clearly proves that the SDK is still using UIWebView, which is causing issues in our app.
On Fri 5. May 2017 at 20:59, 'Deepika Uragayala- MobileAds SDK team' via Google Mobile Ads SDK Developers <google-admob-ads-sdk@googlegroups.com> wrote:
Hi Johannes,

We use WKWebView under the hood and other than that, I would not be able to comment on any internal workings of the SDK.

Regards,
Deepika Uragayala
Mobile Ads SDK Team


On Thursday, May 4, 2017 at 10:02:21 PM UTC-4, Johannes Plunien wrote:
Hi,

but given my information it does not look like it is using WKWebView. Don't you agree? Have a look at the call stack.

Johannes

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.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/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.

Johannes Plunien

unread,
May 8, 2017, 9:27:20 PM5/8/17
to google-adm...@googlegroups.com
Hi Deepika,

thank you, I really appreciate your help! We would like to give this a try. However having a static entry in the info.plist means this would go to 100% of our users instantly. Is it possible to activate this behaviour with some method? This would allow us to run an A/B test on it and verify everything is fine, also only rolling it out to a smaller percentage of our users first.

Thanks,
Johannes

To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsubscrib...@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.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsubscrib...@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.
--
Sent from Gmail Mobile

Deepika Uragayala- MobileAds SDK team

unread,
May 9, 2017, 2:29:09 PM5/9/17
to Google Mobile Ads SDK Developers
Hi Johannes,

We are currently ramping up WKWebview. So if you want the behavior where only a subset of users get WKWebview, then you should just leave your app as is.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

On Monday, May 8, 2017 at 9:27:20 PM UTC-4, Johannes Plunien wrote:
Hi Deepika,

thank you, I really appreciate your help! We would like to give this a try. However having a static entry in the info.plist means this would go to 100% of our users instantly. Is it possible to activate this behaviour with some method? This would allow us to run an A/B test on it and verify everything is fine, also only rolling it out to a smaller percentage of our users first.

Thanks,
Johannes
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.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/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.
--
Sent from Gmail Mobile

Johannes Plunien

unread,
Aug 2, 2017, 3:27:36 AM8/2/17
to Google Mobile Ads SDK Developers
Hi,

unfortunately we see a serious increase of these type of crashes in our application. What's the state of moving towards WKWebView? Any progress there?

You seem to have removed gad_preferred_webview from the latest SDK version, right?

Thanks,
Johannes


On Tuesday, May 9, 2017 at 8:29:09 PM UTC+2, Deepika Uragayala- MobileAds SDK team wrote:
Hi Johannes,

We are currently ramping up WKWebview. So if you want the behavior where only a subset of users get WKWebview, then you should just leave your app as is.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

On Monday, May 8, 2017 at 9:27:20 PM UTC-4, Johannes Plunien wrote:
Hi Deepika,

thank you, I really appreciate your help! We would like to give this a try. However having a static entry in the info.plist means this would go to 100% of our users instantly. Is it possible to activate this behaviour with some method? This would allow us to run an A/B test on it and verify everything is fine, also only rolling it out to a smaller percentage of our users first.

Thanks,
Johannes
To post to this group, send email to google-adm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/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.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/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.

Deepika Uragayala- MobileAds SDK team

unread,
Aug 2, 2017, 3:08:51 PM8/2/17
to Google Mobile Ads SDK Developers
Hi Johannes,

The gad_preferred_webview flag is still valid with the latest version but is now only supported for iOS 9+. I don't have an ETA on when this will be rolled out completely. I will keep you posted if I have any new information from the team.


Regards,
Deepika Uragayala
Mobile Ads SDK Team

Johannes Plunien

unread,
Aug 2, 2017, 11:25:10 PM8/2/17
to google-adm...@googlegroups.com
Hi Deepika,

sorry, you're absolutely right - the setting is still working! Only now I noticed that there's a difference between DFP banner views and AdSense views: The setting seems to be working for banner views only. AdSense ads are still loaded in UIWebView's.

Is there any other setting that allows us to use WKWebView for AdSense as well?

Thanks,
Johannes

To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.

To post to this group, send email to google-adm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.

To post to this group, send email to google-adm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.

To post to this group, send email to google-adm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

---
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/R1-yLiAjPyQ/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.

Deepika Uragayala- MobileAds SDK team

unread,
Aug 3, 2017, 3:02:00 PM8/3/17
to Google Mobile Ads SDK Developers
Hi Johannes,

When you mean AdSense ads, can you confirm whether they are Search Ads? Can you also provide us your Ad Unit ID to investigate further?

Regards,
Deepika Uragayala
Mobile Ads SDK Team


On Wednesday, August 2, 2017 at 11:25:10 PM UTC-4, Johannes Plunien wrote:
Hi Deepika,

sorry, you're absolutely right - the setting is still working! Only now I noticed that there's a difference between DFP banner views and AdSense views: The setting seems to be working for banner views only. AdSense ads are still loaded in UIWebView's.

Is there any other setting that allows us to use WKWebView for AdSense as well?

Thanks,
Johannes
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.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/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.
--
Sent from Gmail Mobile

--

---
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/R1-yLiAjPyQ/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.

Christian Kraus

unread,
Aug 22, 2017, 9:43:30 AM8/22/17
to Google Mobile Ads SDK Developers
Hi Deepika,

can you please confirm that the gad_preferred_webview flag also works for interstitial ads? I tried setting gad_preferred_webview to wkwebview, but interstitial ads are still using UIWebView instead of WKWebView.

Best regards
Christian  

Deepika Uragayala- MobileAds SDK team

unread,
Aug 22, 2017, 3:01:04 PM8/22/17
to Google Mobile Ads SDK Developers
Hi Christian,

Can you provide me the SDK version you are using? Make sure that you are using the latest version and try again.

Let us know if you are still seeing the issue.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

Christian Kraus

unread,
Aug 23, 2017, 8:56:38 AM8/23/17
to Google Mobile Ads SDK Developers
Hi Deepika,

thanks for your help. I have updated the SDK to the latest release and now the interstitial ads are using WKWebView. I am a bit suprised that my custom NSURLProtocol class is still used for loading interstitial ad though the request is coming from WKWebView. Are you loading the ads directly with WKWebView or are you loading the ads through a custom engine and only using WKWebView for rendering the ad content? Is there anything I can do in my custom NSURLProtocol class to ignore ad requests from your SDK? 

Best regards
Christian

Deepika Uragayala- MobileAds SDK team

unread,
Aug 23, 2017, 3:17:34 PM8/23/17
to Google Mobile Ads SDK Developers
Hi Christian,

We would not be able to comment on any internal workings of the SDK on the forum. However, please note that the SDK is still in the process to migrate to WKWebView and is not completely done. But just so I understand what is being passed to the UIWebView, can you share what custom protocols are you passing when subclassing NSURLProtocol? 

Regards,
Deepika Uragayala
Mobile Ads SDK Team

Christian Kraus

unread,
Aug 28, 2017, 12:53:26 PM8/28/17
to Google Mobile Ads SDK Developers
Hi Deepika,

I have a custom NSURLProtocol subclass for all http and https traffic and I'm looking for a solution to ignore requests which come from the Admob SDK. For other third-party SDKs (for example the Google Analytics SDK) it is possible to examine the User-Agent and ignore those requests, but the Admob SDK does not use a special User-Agent. I thought when the Admob SDK is using WKWebView my custom NSURLProtocol subclass is ignored, because WKWebView does not support custom NSURLProtocol classes, but unfortunately this is not the case.

Best regards
Christian

Deepika Uragayala- MobileAds SDK team

unread,
Aug 28, 2017, 3:53:40 PM8/28/17
to Google Mobile Ads SDK Developers
Hi Christian,

I will have to confirm about this with the rest of our team. I'll get back to you as soon as I have some information from our team.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

Christian Kraus

unread,
Sep 4, 2017, 7:25:47 AM9/4/17
to Google Mobile Ads SDK Developers
Hi Deepika,

thanks for your help.

Best regards
Christian

Deepika Uragayala- MobileAds SDK team

unread,
Sep 15, 2017, 4:39:07 PM9/15/17
to Google Mobile Ads SDK Developers
Hi there,

WKWebView is now enabled for Search Ads and is live with the latest v7.23 of the SDK.

Regards,
Deepika Uragayala
Mobile Ads SDK Team


Reply all
Reply to author
Forward
0 new messages