Bug 176625 - decidePolicyForNavigationAction's decisionHandler is not getting called if it is in Async Block.
Summary: decidePolicyForNavigationAction's decisionHandler is not getting called if it...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Local Build
Hardware: iPhone / iPad iOS 11
: P1 Blocker
Assignee: Nobody
URL:
Keywords: Regression
Depends on:
Blocks:
 
Reported: 2017-09-08 12:46 PDT by Raghavendra
Modified: 2017-10-11 09:01 PDT (History)
7 users (show)

See Also:


Attachments
Sample WkWebView app for simulating issue in decidePolicyForNavigationAction (59.91 KB, application/zip)
2017-09-08 12:46 PDT, Raghavendra
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raghavendra 2017-09-08 12:46:25 PDT
Created attachment 320290 [details]
Sample WkWebView app for simulating issue in decidePolicyForNavigationAction

Hi,

We are having issue with decidePolicyForNavigationAction callback function.  We found that evaluateJavaScript method fails to invoke its completionHandler callback when called within decidePolicyForNavigationAction delegate and before its decisionHandler was called.
While this is working in current iOS10 but fails on iOS11 beta. This code flow is as per Apple’s documentation - https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview?language=objc

decisionHandler never gets called if it is in Async block in decidePolicyForNavigationAction delegate callback.

Below is the code snippet which works in iOS10 & not on iOS11.

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{
    NSLog(@"decidePolicyForNavigatiAction");

    [_webView evaluateJavaScript:@"document.getElementById('demo').innerHTML = \"Change Content of Paragraph\"" completionHandler:^(id result, NSError * _Nullable error) {
        
        NSLog(@"The Result is:%@",result);
       decisionHandler(WKNavigationActionPolicyCancel);   //Never gets called

    }];
}



Thanks
Raghavendra
Comment 1 Raghavendra 2017-10-11 09:01:59 PDT
Looks like issue solved in latest iOS 11.1 Beta 2 – 604.3.3