Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash on iOS10.3 #267

Closed
jinjuezhou opened this issue Feb 8, 2017 · 9 comments
Closed

crash on iOS10.3 #267

jinjuezhou opened this issue Feb 8, 2017 · 9 comments

Comments

@jinjuezhou
Copy link

hi,
I have receive crash Completion handler passed to -[WKWebViewJavascriptBridge webView:decidePolicyForNavigationAction:decisionHandler:] was called more than once
only on iOS10.3

@summerdev10
Copy link

I'm getting this too, any ideas for a workaround?

@mengxiangyue
Copy link

The crash is in simulator,not present in iPhone.
in WKWebViewJavascriptBridge.m, modify like this (comment with add this)

- (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 isWebViewJavascriptBridgeURL:url]) {
        if ([_base isBridgeLoadedURL:url]) {
            [_base injectJavascriptFile];
        } else if ([_base isQueueMessageURL:url]) {
            [self WKFlushMessageQueue];
        } else {
            [_base logUnkownMessage:url];
        }
        decisionHandler(WKNavigationActionPolicyCancel);
        return; // add This
    }
    
    if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) {
        [_webViewDelegate webView:webView decidePolicyForNavigationAction:navigationAction decisionHandler:decisionHandler];
    } else {
        decisionHandler(WKNavigationActionPolicyAllow);
    }
}

@keewon
Copy link

keewon commented Mar 22, 2017

Almost same as my PR: #272

@totzcc
Copy link

totzcc commented Jun 26, 2017

crash on iOS 11.0 with Xcode 9 beta 2 (9M137d)

add return can fix it, For more information, see the comments above

@moyunmo
Copy link

moyunmo commented Jul 17, 2017

@mengxiangyue Did you pull request for this issue?

@darvintang
Copy link

什么时候能解决这个问题?修改源码就不能用pod管理了,痛苦。

@mengxiangyue
Copy link

我没有用pod,因为我也添加了 原生调用js 不存在的方法 返回9999的能力,另外添加了白名单功能

@cythb
Copy link

cythb commented Sep 20, 2017

With reference to this, I hope to be of help to you. a0cfcf6

@marcuswestin
Copy link
Owner

Fixed in latest release (6.0.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants