White screen after switching from UIWebView to WKWebView (device-only)

JeffreyBakkerJeffreyBakker USUniversity ✭✭
edited June 6 in Xamarin.iOS

On a project that has existed for several years, we have decided to try WKWebView to replace the deprecated UIWebView, after weeks of not finding any better leads to a performance issue (see post "Javascript engine extremely slow after 2+ minutes of screen lock").

It appears to work fine in iOS simulator, but on a physical iPhone 7P (iOS 12.2) there is nothing but a permanent white screen (the status bar is present) after the launch image. Our UI is 100% comprised of a few WebViews each taking up different portions of the screen. The WebViews were originally created in a xib file (pre-existence of constraint system), and I edited the .xib to change from UIWebView to WKWebView in a way that does not change any layout or constraints.

Unfortunately, the code base is too massive (and proprietary) to post a sample that would reproduce it, and I have failed to create a standalone Xamarin.iOS app that is able to reproduce it, but sure have tried.

Is there anything special you need to do to get WKWebView to display properly, that wasn't required for UIWebView?

Update: The WebViews are loading .html files in AppDelegate.FinishedLaunching(), which steps through entirely without error. I have a IWKScriptMessageHandler which should hit on breakpoints after the HTML content is loaded (via Javascript call to webkit.messageHandlers) but they are not hitting. These breakpoints do hit as expected on iOS Simulator.

Best Answer

  • JeffreyBakkerJeffreyBakker US ✭✭
    Accepted Answer

    After implementing a WKNavigationDelegate and overriding DidFailProvisionalNavigation() to set a breakpoint I have found the following errors:

    NSPOSIXErrorDomain
    The operation couldn’t be completed. Operation not permitted
    {{
        "_NSURLErrorFailingURLSessionTaskErrorKey" = "LocalDataTask <D1AE26BD-71D0-45BB-90CB-E0BD2F0091F3>.<1>";
        "_WKRecoveryAttempterErrorKey" = "<WKReloadFrameErrorRecoveryAttempter: 0x282c3aae0>";
        "_kCFStreamErrorCodeKey" = 1;
        "_kCFStreamErrorDomainKey" = 1;
    }}
    

    and

    "kCFErrorDomainCFNetwork"
    "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 1.)"
    {{
        "_NSURLErrorFailingURLSessionTaskErrorKey" = "LocalDataTask <8581E770-74AF-424B-A436-44AABD47975E>.<1>";
        "_WKRecoveryAttempterErrorKey" = "<WKReloadFrameErrorRecoveryAttempter: 0x282c22560>";
    }}
    

    Which gives away the biggest clue. I must use LoadFileUrl() for loading local .html files.

Answers

  • JeffreyBakkerJeffreyBakker USUniversity ✭✭
    Accepted Answer

    After implementing a WKNavigationDelegate and overriding DidFailProvisionalNavigation() to set a breakpoint I have found the following errors:

    NSPOSIXErrorDomain
    The operation couldn’t be completed. Operation not permitted
    {{
        "_NSURLErrorFailingURLSessionTaskErrorKey" = "LocalDataTask <D1AE26BD-71D0-45BB-90CB-E0BD2F0091F3>.<1>";
        "_WKRecoveryAttempterErrorKey" = "<WKReloadFrameErrorRecoveryAttempter: 0x282c3aae0>";
        "_kCFStreamErrorCodeKey" = 1;
        "_kCFStreamErrorDomainKey" = 1;
    }}
    

    and

    "kCFErrorDomainCFNetwork"
    "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 1.)"
    {{
        "_NSURLErrorFailingURLSessionTaskErrorKey" = "LocalDataTask <8581E770-74AF-424B-A436-44AABD47975E>.<1>";
        "_WKRecoveryAttempterErrorKey" = "<WKReloadFrameErrorRecoveryAttempter: 0x282c22560>";
    }}
    

    Which gives away the biggest clue. I must use LoadFileUrl() for loading local .html files.

Sign In or Register to comment.