Recently ran into a crash in our app:
EXC_BREAKPOINT 0x00000001c5c8986c
static URLRequest._unconditionallyBridgeFromObjectiveC(_:)
It's coming from a webView decide policy where we access the request property:
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
let req = navigationAction.sourceFrame.request
}
I believe the problem is on this line in swift lib: https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/URLRequest.swift#L298
There are no guards in place here, and it seems like on the objc side it's possible that the request is nil.
My question is regarding how to get around the objc to swift bridge. Would KVC avoid that?
if let req = navigationAction.sourceFrame.value(forKey: "request") as NSURLRequest {
//do stuff
}
If there's no way to circumvent the objc to swift bridge it's a crash we will have to live with? It is not happening too frequently, but enough that we would love to fix.