Open relaxstis opened 7 years ago
我们在这里遇到的crash是正常请求远程服务端资源, 在decidePolicyForNavigationAction
代理方法里处理navigationAction.navigationType
以及URL scheme
来决定WKNavigationActionPolicy
,crash信息如下
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
@sunTie 你项目里面有用到 WKWebViewJavascriptBridge 么?如果有的话,请参考
https://github.com/marcuswestin/WebViewJavascriptBridge/issues/278
在decisionHandler(WKNavigationActionPolicyCancel);
下面加上return;
我这边按照这个解决方案处理好了。
- (void)webView:(WKWebView *)webView
decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
if (webView != _webView) { return; }
NSURL *url = navigationAction.request.URL;
__strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate;
if ([_base isCorrectProcotocolScheme:url]) {
if ([_base isBridgeLoadedURL:url]) {
[_base injectJavascriptFile];
} else if ([_base isQueueMessageURL:url]) {
[self WKFlushMessageQueue];
} else {
[_base logUnkownMessage:url];
}
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) {
[_webViewDelegate webView:webView decidePolicyForNavigationAction:navigationAction decisionHandler:decisionHandler];
} else {
decisionHandler(WKNavigationActionPolicyAllow);
}
}
This problem is based on iOS11 beta,the details are:
the request:
pragma mark - WKNavigationDelegate:
情况说明:前面使用了loadRequest的请求方式,奔溃的地方在后面的代理decidePolicyForNavigationAction:使用WKNavigationActionPolicyAllow奔溃;在iOS11 beta以下正常.
经调试:采用loadHtmlWithString时不调用baseurl不会奔溃,但是肯定没有使用和加载数据
奔溃信息:Thread 1: signal SIGABRT
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
libc++abi.dylib: terminate_handler unexpectedly threw an exception
Ask for your advice, thank you!!