Skip to content

I get crash in iOS11 ..... #302

Closed
Closed
@huanghualove

Description

@huanghualove

'Completion handler passed to -[WKWebViewJavascriptBridge webView:decidePolicyForNavigationAction:decisionHandler:] was not called'

reason: 'Completion handler passed to -[WKWebViewJavascriptBridge webView:decidePolicyForNavigationAction:decisionHandler:] was called more than once'

How to resolve this problem ?? thank you .

WVJB Bug Report

Thanks for reporting an issue with WebViewJavascriptBridge.

Do these 4 things and I will fix your problem!

  1. Go to https://github.com/marcuswestin/WebViewJavascriptBridge and click Fork.
  2. Clone your fork, cd into it and run make test. All tests should pass!
  3. Edit Tests/WebViewJavascriptBridgeTests/BridgeTests.m and create a new, failing test which demostrates your issue.
  4. Create a pull request for https://github.com/marcuswestin/WebViewJavascriptBridge

That's it!

I will take it from there and promise that I'll fix your problem ASAP.

If you don't do this then I can't help you!

And I probably won't :)

Cheers,
@marcuswestin

Activity

madordie

madordie commented on Sep 14, 2017

@madordie

@marcuswestin

This is a must-have crash


info:

#0 Thread
NSInternalInconsistencyException
Completion handler passed to -[WKWebViewJavascriptBridge webView:decidePolicyForNavigationAction:decisionHandler:] was called more than once

and stack info

CoreFoundation	0x0000000186187d38 0x0000000186046000 + 1318200
1 libobjc.A.dylib	0x000000018569c528 objc_exception_throw + 56
2 CoreFoundation	0x0000000186187c80 0x0000000186046000 + 1318016
3 WebKit	0x00000001951acbdc 0x000000019517b000 + 203740
4 WebKit	0x00000001951f1700 0x000000019517b000 + 485120
5 xxxx_ent	0x0000000101472840 _T0SC24WKNavigationActionPolicyOIyBy_ABIxy_TR + 40
6 xxxx_ent	0x00000001014726cc _T014xxxx_ent24XXXBaseWebViewControllerC03webE0ySo05WKWebE0C_So18WKNavigationActionC15decidePolicyForySC0ijL0Oc15decisionHandlertF + 2860
7 xxxx_ent	0x00000001014edd18 _T014xxxx_ent20XXXWebViewControllerC03webD0ySo05WKWebD0C_So18WKNavigationActionC15decidePolicyForySC0hiK0Oc15decisionHandlertF + 1776
8 xxxx_ent	0x0000000101500108 _T014xxxx_ent20XXXWebViewControllerC03webD0ySo05WKWebD0C_So18WKNavigationActionC15decidePolicyForySC0hiK0Oc15decisionHandlertFTo + 180
9 WebViewJavascriptBridge	0x000000010546b6b0 -[WKWebViewJavascriptBridge webView:decidePolicyForNavigationAction:decisionHandler:] + 712
10 WebKit	0x00000001951ef254 0x000000019517b000 + 475732
11 WebKit	0x00000001953571b4 0x000000019517b000 + 1950132
12 WebKit	0x000000019537eac8 0x000000019517b000 + 2112200
13 WebKit	0x0000000195377bf4 0x000000019517b000 + 2083828
14 WebKit	0x00000001951ecba8 0x000000019517b000 + 465832
15 WebKit	0x00000001953c98b4 0x000000019517b000 + 2418868
16 WebKit	0x00000001951af8b0 0x000000019517b000 + 215216
17 WebKit	0x00000001951ad0d4 0x000000019517b000 + 205012
18 WebKit	0x00000001951afae0 0x000000019517b000 + 215776
19 JavaScriptCore	0x000000018d3b4d10 0x000000018ca87000 + 9624848
20 JavaScriptCore	0x000000018d3b4fd0 0x000000018ca87000 + 9625552
21 CoreFoundation	0x0000000186130358 0x0000000186046000 + 959320
22 CoreFoundation	0x00000001861302d8 0x0000000186046000 + 959192
23 CoreFoundation	0x000000018612fb60 0x0000000186046000 + 957280
24 CoreFoundation	0x000000018612d738 0x0000000186046000 + 948024
25 CoreFoundation	0x000000018604e2d8 CFRunLoopRunSpecific + 436
26 GraphicsServices	0x0000000187edff84 GSEventRunModal + 100
27 UIKit	0x000000018f5fa880 UIApplicationMain + 208
28 xxxx_ent	0x0000000101000c40 main + 444
29 libdyld.dylib	0x0000000185b7256c 0x0000000185b71000 + 5484
wealon

wealon commented on Sep 15, 2017

@wealon

i have the same bug

ranshon

ranshon commented on Sep 18, 2017

@ranshon

i have the same bug

huanghualove

huanghualove commented on Sep 18, 2017

@huanghualove
Author

So how do we solve this problem?

ranshon

ranshon commented on Sep 18, 2017

@ranshon

this bug occur in XCode9 iOS11.

huanghualove

huanghualove commented on Sep 18, 2017

@huanghualove
Author

maybe you can add this:

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-------
}

madordie

madordie commented on Sep 19, 2017

@madordie

in my project.

if WebViewJavascriptBridgeBase().isWebViewJavascriptBridgeURL(url) {
    return
}
decisionHandler(.allow)

Can be resolved by the above code. But do not know will not cause other effects.

可以看这里

InfAspire

InfAspire commented on Sep 19, 2017

@InfAspire

Also - please note that the current testPerformanceExample test fails when you run make test with XCode 9 installed.

Test Case '-[WebViewJavascriptBridgeTests.BridgeTests testPerformanceExample]' started.
WebViewJavascriptBridge-master/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m:155: error: -[WebViewJavascriptBridgeTests.BridgeTests testPerformanceExample] : failed: caught "NSInternalInconsistencyException", "Completion handler passed to -[WKWebViewJavascriptBridge webView:decidePolicyForNavigationAction:decisionHandler:] was called more than once"
...
Test Case '-[WebViewJavascriptBridgeTests.BridgeTests testPerformanceExample]' failed (0.849 seconds).
longshao521

longshao521 commented on Sep 20, 2017

@longshao521

I have the same bug.

yinanwang1

yinanwang1 commented on Sep 20, 2017

@yinanwang1

I have the same bug. I found this bug in the iOS 11 beta one month ago. I thought this crash must be resoled in the iOS 11. But it did not. So Apps will crash if the user upgrade their iPhone.

AdamYLK

AdamYLK commented on Sep 20, 2017

@AdamYLK

i have the same bug but see something beside, when run in xcode8 and ios11 the crash didn't happened.
the bug in xcode9 with ios11,i think it may crashed by xcode9

fifyrio

fifyrio commented on Sep 20, 2017

@fifyrio

I have the same bug.

zeroskylian

zeroskylian commented on Sep 20, 2017

@zeroskylian

set WKWebview navigationDelegate

coderWeil

coderWeil commented on Sep 20, 2017

@coderWeil

I have the same bug ,thank for @huanghualove ,I had got it

NXZXing

NXZXing commented on Sep 20, 2017

@NXZXing

I have the same bug.

29 remaining items

Loading
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

      Participants

      @marcuswestin@benleiken@cythb@alex-chan@InfAspire

      Issue actions

        I get crash in iOS11 ..... · Issue #302 · marcuswestin/WebViewJavascriptBridge