Skip to content

crash on iOS10.3 #267

Closed
Closed
@jinjuezhou

Description

@jinjuezhou

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

Activity

summerdev10

summerdev10 commented on Feb 17, 2017

@summerdev10

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

mengxiangyue

mengxiangyue commented on Mar 22, 2017

@mengxiangyue

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

keewon commented on Mar 22, 2017

@keewon

Almost same as my PR: #272

totzcc

totzcc commented on Jun 26, 2017

@totzcc

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

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

moyunmo

moyunmo commented on Jul 17, 2017

@moyunmo

@mengxiangyue Did you pull request for this issue?

darvintang

darvintang commented on Sep 11, 2017

@darvintang

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

mengxiangyue

mengxiangyue commented on Sep 18, 2017

@mengxiangyue

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

cythb

cythb commented on Sep 20, 2017

@cythb

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

marcuswestin

marcuswestin commented on Nov 8, 2017

@marcuswestin
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @marcuswestin@keewon@mengxiangyue@cythb@jinjuezhou

        Issue actions

          crash on iOS10.3 · Issue #267 · marcuswestin/WebViewJavascriptBridge