WKWebView didFinishNavigation is not working with frame/iframes

I am trying to load a html which has 2 frames in it using WKWebView. I am getting all the navigation delegates for main frame once but not getting didCommit and didFinish callback for subframes.

My sample html is like this:

https://example.com <html><head><base href="https://example.com"></head><frameset framespacing="0" rows="*,0" frameborder="0" noresize><frame name="sco" src="https://example.com//assets/s/uruq3acajh9u/x/mobile/path/loading.html"><frame name="adaptor" src="https://example.com//assets/s/uruq3acajh9u/content/mobile/path/1.html?sco_url=https://example.com/content/elearningngx/VHDRczdEy5kO_pRfKsNJEA/1571433806/0088Z2lPcUR4MVljWWlPUVYvSjNrby9OVjJzbk84OENkN1h3SVl3UVBPMG9sb3lXNFFsaHUwT2xDbVhFTzVpMWdiNQ==RnJpIE9jdCAxOCAxMzoyMzoyNiBVVEMgMjAxOQ==/eot/index.html"></frameset></html>
func setupWebView(){
        if (self.webView != nil){
            self.webView.removeFromSuperview()
        }
       
        HTTPCookieStorage.shared.cookieAcceptPolicy = .always
       
        let userContentController = WKUserContentController()
        userContentController.addUserScript(HTMLViewScripts.viewportScript)
    
       
        let pref = WKPreferences()
        pref.javaScriptEnabled = true
        pref.javaScriptCanOpenWindowsAutomatically = true
        pref.setValue(true, forKey: "allowFileAccessFromFileURLs")
        pref.setValue(true, forKey: "_allowUniversalAccessFromFileURLs")
       
        let wkWebConfig = WKWebViewConfiguration()
        wkWebConfig.preferences = pref
        wkWebConfig.userContentController = userContentController
       
        let wkWebSiteStore = WKWebsiteDataStore.nonPersistent()
        wkWebConfig.websiteDataStore = wkWebSiteStore
       
        self.webView = WKWebView(frame: CGRect(x: 0, y: 0, width: Constants.screenSize.width, height: self.playerContainer.frame.size.height), configuration: wkWebConfig)
        self.webView.navigationDelegate = self
        self.webView.uiDelegate = self
        self.playerContainer.addSubview(self.webView)
    }


Also same issue with evaluateJavaScript as well. I am not getting any callback when loading "about:blank" using evaluateJavaScript. Seems same frames related issue.


Also unable to load file url using loadFileURL



Any leads would be appriciated. Thanks in advance.

Replies

I'm also seeing this issue, though with a slightly different use case. I am getting WKNavigationDelegate calls like func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) for an iFrame load, but I'm not seeing any of the follow up status calls once I pass .allow to the decisionHandler.