When using a WKWebView to navigate to a local HTML page, I encountered an issue with a remote Javascript asset tag that never finished downloading. This occurred even when the iOS device was not connected to the internet or had slow internet speeds.
The problem is that the WKWebView does not abort the download of this asset nor does it trigger any callbacks in the WKNavigationDelegate. This results in users being stuck on a blank HTML page that never fully loads and does not generate any errors.
In some cases, debugging with Safari's remote iOS Javascript debugger revealed an error message stating "Failed to load resource: The Internet connection appears to be offline" in the console log. However, on certain devices in Airplane Mode, the WKWebView does not seem to timeout or give up, preventing any WKNavigationDelegate callbacks from being executed.
To replicate this issue, one can use the iOS 8.2 simulator with a WKWebView iOS application, navigate to a locally served HTML file, insert a script tag with a remote URL, and then simulate a "100% Loss" Internet connection using Apple's Network Link Conditioner.
Is there a recommended approach to force a WKWebView to timeout or return an error/success callback to its WKNavigationDelegate in such situations?