WKWebView - urlScheme + didFailProvisionalLoadForFrame

I have a scenario where the user needs to login using SSO, and then the server will use a url-scheme to communicate with my app. If I'm opening an external browser - everything works great. But I tried to use an embedded browser instead (WebView), and for some reason I'm getting this unclear error:

[ProcessSwapping] 0x11fd863f0 - ProvisionalPageProxy::didFailProvisionalLoadForFrame: pageProxyID=23 webPageID=34, frameID=3, navigationID=4

At the Console I saw more similar issues, like:

0x11fd863f0 - ProvisionalPageProxy::didFailProvisionalLoadForFrame: pageProxyID=23 webPageID=34, frameID=3, navigationID=4

<nw_activity 16:1 [E08406EE-456B-4302-913A-6C46229FDFC7] (reporting strategy default) complete (reason cancelled)> complete with reason 4 (cancelled), duration 599ms

How can I tell what's the problem and how to fix it?

P.S In order to debug/fix it, I tried to implement the WKNavigationDelegate protocol, so I could see that I'm getting this error as well:

error:Error Domain= Code😮 "Redirection to URL with a scheme that is not HTTP(S)" UserInfo={_WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x600002b1c200>, NSErrorFailingURLStringKey=mycustomurlscheme://someresponse

I'm not sure why the url scheme must be http(s) in this case.

Answered by Apple Designer in 678796022

For security reasons, the Fetch standard doesn't allow http(s) servers to redirect to non-http(s) urls.

I see a few obvious options, though there are probably more.

  • You could leave the server response as-is, capture the error, and then load the custom URL scheme URL yourself.

  • If you have the flexibility to change the server's response, you could have it communicate the target URL differently (as a query parameter in the URL string, perhaps) and have your app load it manually.

Accepted Answer

For security reasons, the Fetch standard doesn't allow http(s) servers to redirect to non-http(s) urls.

I see a few obvious options, though there are probably more.

  • You could leave the server response as-is, capture the error, and then load the custom URL scheme URL yourself.

  • If you have the flexibility to change the server's response, you could have it communicate the target URL differently (as a query parameter in the URL string, perhaps) and have your app load it manually.

Thanks for the answer! But while this explain the issue, any idea why the same scenario works when it's done with an external browser? Https server, which opens my custom URL scheme, and everything works as expected.

I'm not sure what you mean by "works when it's done with an external browser"?

Do you mean loading the exact same HTTP content in Safari does open the custom URL scheme?

If so, that would be because Safari manually hands the URL off to LaunchServices, like I suggested above.

"Do you mean loading the exact same HTTP content in Safari does open the custom URL scheme?" - Yes, that's what I meant. Thanks for the explanation!

I'm having the same problem with a map download link from usgs. The download links work in safari on osx(11.4) and (iOS15.02) IPad/Iphone.

When using WKWebView with Xcode 12.5/13. on the iPhone I am getting the error

XX XXXX V1.1[59585:3775699] [Process] 0x15684b018 - [pageProxyID=5, webPageID=6, PID=59586] WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = WebKitErrorDomain, code = 102

The download links act dead, there is no response when touched. Other links are working. If the link is long touched and get a click feedback, then the page shows the copy/lookup selection at the top of web view page completely seperate from the link touch like webView doesn't know how to respond to the link.

edit: Just tested the IPad and it has the same results as the iPhone.

WKWebView - urlScheme + didFailProvisionalLoadForFrame
 
 
Q