Skip to content

return after decisionHandler called to avoid call it more than once - #296

Merged
marcuswestin merged 1 commit into
marcuswestin:masterfrom
wrlqwe:master
Nov 8, 2017
Merged

return after decisionHandler called to avoid call it more than once#296
marcuswestin merged 1 commit into
marcuswestin:masterfrom
wrlqwe:master

Conversation

@wrlqwe

@wrlqwe wrlqwe commented Jul 24, 2017

Copy link
Copy Markdown
Contributor

in the latest version in [WKWebViewJavascriptBridge webView:decidePolicyForNavigationAction:decisionHandler:], after decisionHander executed:

    if ([_base isWebViewJavascriptBridgeURL:url]) {
        if ([_base isBridgeLoadedURL:url]) {
            [_base injectJavascriptFile];
        } else if ([_base isQueueMessageURL:url]) {
            [self WKFlushMessageQueue];
        } else {
            [_base logUnkownMessage:url];
        }
        decisionHandler(WKNavigationActionPolicyCancel);
    }

decisionHandler passed to _webViewDelegate and the delegate method may call decisionHandler again, most conditions it work well, but it leads crash on my iOS11+XCode9 beta environment.
In my view, a decision cannot be made for twice, the decisionHandler that consumed should not pass out side of this method, I hope this commit can fix it.

@wrlqwe

wrlqwe commented Jul 24, 2017

Copy link
Copy Markdown
Contributor Author

please review my code, I'm not sure this commit meets the requirements for repo users or is it good enough...

@marcuswestin

Copy link
Copy Markdown
Owner

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants