Reputation: 24325
Why would the below stack trace throw a EXC_BAD_ACCESS KERN_INVALID_ADDRESS because of the WKWebView? I can't tell where this is happening either.
I dont know where this is happening but here is my reference to the WKWebView in one of my nibs.
@property (strong, nonatomic) IBOutlet WKWebView *bracketWebView;
StackTrace
Crashed: com.apple.main-thread
0 WebKit 0x2af40854 WebKit::WebPageProxy::close() + 11
1 WebKit 0x2aff496d -[WKWebView dealloc] + 120
2 WebKit 0x2aff496d -[WKWebView dealloc] + 120
3 WebKit 0x2aff48f1 -[WKWebView initWithCoder:] + 20
4 UIKit 0x28bc310f UINibDecoderDecodeObjectForValue + 782
5 UIKit 0x28bc2df5 -[UINibDecoder decodeObjectForKey:] + 296
6 UIKit 0x28aab4a5 -[UIRuntimeConnection initWithCoder:] + 160
7 UIKit 0x28bc310f UINibDecoderDecodeObjectForValue + 782
8 UIKit 0x28bc30a1 UINibDecoderDecodeObjectForValue + 672
9 UIKit 0x28bc2df5 -[UINibDecoder decodeObjectForKey:] + 296
10 UIKit 0x28aaaa0b -[UINib instantiateWithOwner:options:] + 1110
11 UIKit 0x2895daa3 -[UIViewController _loadViewFromNibNamed:bundle:] + 322
12 UIKit 0x28730ffb -[UIViewController loadView] + 142
13 UIKit 0x285f6a1f -[UIViewController loadViewIfRequired] + 150
14 UIKit 0x2860ee71 -[UIViewController __viewWillAppear:] + 124
15 UIKit 0x287a51e5 -[UINavigationController _startCustomTransition:] + 1040
16 UIKit 0x286b34a7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 650
17 UIKit 0x286b31b5 -[UINavigationController __viewWillLayoutSubviews] + 52
18 UIKit 0x286b312b -[UILayoutContainerView layoutSubviews] + 214
19 UIKit 0x285f2a73 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 714
20 QuartzCore 0x2668abcd -[CALayer layoutSublayers] + 128
21 QuartzCore 0x26686375 CA::Layer::layout_if_needed(CA::Transaction*) + 348
22 QuartzCore 0x26686209 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
23 QuartzCore 0x266856d1 CA::Context::commit_transaction(CA::Transaction*) + 368
24 QuartzCore 0x266853a5 CA::Transaction::commit() + 520
25 QuartzCore 0x2667eb2b CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 138
26 CoreFoundation 0x2403d6c9 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
27 CoreFoundation 0x2403b9cd __CFRunLoopDoObservers + 280
28 CoreFoundation 0x2403bdff __CFRunLoopRun + 958
29 CoreFoundation 0x23f8b229 CFRunLoopRunSpecific + 520
30 CoreFoundation 0x23f8b015 CFRunLoopRunInMode + 108
31 GraphicsServices 0x2557bac9 GSEventRunModal + 160
32 UIKit 0x2865f189 UIApplicationMain + 144
33 com.exposure.0 0xbad0d main + 15 (main.m:15)
34 ??? 0x23c33873 (Missing)
Upvotes: 1
Views: 859
Reputation: 24325
This seemed to be a Firebase Admob issue. Adding the below fixed it, no issues since.
<key>gad_preferred_webview</key>
<string>wkwebview</string>
https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/ios/I4EEWrPPbSc
Upvotes: 0
Reputation: 221
WebKit still attempt to call the deallocated object 0x2aff496d WKWebView.
Your IBOutlet has strong attribute, it's not necessary, because nib keep strong reference on it's subviews.
Try to make the attribute weak:
@property (weak, nonatomic) IBOutlet WKWebView *bracketWebView;
Upvotes: 0
Reputation: 2142
Check this code:
lazy var contentWebView: WKWebView = {
let webView = WKWebView(frame: .zero)
webView.navigationDelegate = self
webView.allowsLinkPreview = true
webView.uiDelegate = self
webView.backgroundColor = .clear
webView.scrollView.isScrollEnabled = true
webView.scrollView.backgroundColor = .clear
webView.sizeToFit()
return webView
}()
Upvotes: 0
Reputation: 634
Are you running the app on the iOS 11 or above? Since there was a bug in [WKWebView initWithCoder:] that was only fixed in iOS 11, which causes the crash.
Before iOS11, we should create the instance of WkWebView like below:
let webConfiguration = WKWebViewConfiguration()
webConfiguration.userContentController.add(self, name: "callbackHandler")
wkWebView = WKWebView(frame: contentView.bounds, configuration: webConfiguration)
wkWebView.allowsLinkPreview = false
wkWebView.translatesAutoresizingMaskIntoConstraints = false
wkWebView.navigationDelegate = self
contentView.addSubview(wkWebView)
Upvotes: 1