WKWebView loadFileURL(url, allowingReadAccessTo) locks the internal WKWebView sandbox, so subsequent requests outside the readAccessURL always fail

Number:rdar://45346962 Date Originated:10-17-2018
Status:Open Resolved:
Product:macOS + SDK (WebKit/WKWebView) Product Version:Xcode 10
Classification:Bug Reproducible:Always
WKWebView loadFileURL(url, allowingReadAccessTo) seems to lock the internal WKWebView sandbox, so subsequent requests outside the initial readAccessURL always fail. Doing an intermediate load via load(request) seems to "clear" the readAccessURL/sandbox and will cause the request to work. Doing so requires a lot of workarounds and hacks to keep the delegate and backForwardList useful though.

Steps to Reproduce:
1. Instantiate a WKWebView, set the navigationDelegate, and implement the didFailProvisionalNavigation(...) delegate method.

Note: {file/file2} below should be in different directories to see the issue. This is NOT an App Sandbox issue - the App Sandbox can be disabled - this is a WKWebView internal sandbox issue.

2. Call webView.loadFileURL(file, allowingReadAccessTo: file)
3. Call webView.loadFileURL(file2, allowingReadAccessTo: file2)

Expected Results:
The two requests should complete successfully.

Actual Results:
The second request will always fail and the didFailProvisionalNavigation(...) delegate method will be called with the error: Error Domain=kCFErrorDomainCFNetwork Code=1

Xcode 10.0 (10A255)

macOS 10.13.6



Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!