title: How to determine why WKWebView is crashing
body: <p>I am using WKWebView in a Swift app built for iOS 8+. I use instances of WKWebView in a variety of views in my app, e.g. in each of the tabs in my tab view controller, the interface is based on WKWebView. </p>
  
  <p>I and my testers have noticed these views sometimes go completely blank, and after researching that issue, it seems that WKWebView can crash, and the blank view is the result. Luckily, it doesn't bring down the app due to the way WKWebView operates, but I also am not clear on how to trap/log information about what caused it to crash (if that is actually what is happening).</p>
  
  <p>How can I determine if/why a WKWebView has crashed? </p>
  
  <p>My current workaround for the issue is that I use KVO (actually, Facebook's <a href="https://github.com/facebook/KVOController">KVOController</a>), to monitor the "URL" property of the WKWebView, and if it goes from non-nil to nil, I assume a crash has happened, and I reload the webview:</p>
  
  <pre><code>kvoController?.observe(webView, keyPath: "URL", options: NSKeyValueObservingOptions.New|NSKeyValueObservingOptions.Old) { (areaViewController, webView, change) -&gt; Void in
      if change[NSKeyValueChangeNewKey] is NSNull &amp;&amp; !(change[NSKeyValueChangeOldKey] is NSNull) {
          areaViewController.setup() // reload our webview
      }
  }
  </code></pre>
  
  <p>But obviously it would be nice to figure out the root cause of the crash.</p>