Cordova WKWebView white screen on iPhone 11 Pro only


Our customers report random white screens on app launch on iOS devices. While almost all devices happen to launch the app successfully after some retries the iPhone 11 Pro always starts with a white screen. That got me (after long blackbox digging) to the assumption that fast iPhones have the Problem and that WKWebView maybe starts with a race condition.

On my iPhone 11 Pro simulator I luckily got a 50/50 chance of a white screen so I started debugging CDVWKWebKitViewEngine.m. I have absolutely no knowledge in Objective-C so I just restarted over and over again to spot randomly the differences in the call stack. While doing this I slowly got an understanding of how the plugin might be working under the hood. userContentController:didReceiveScriptMessage seems to play a role in the successful startup of the container and all scripts and assets being loaded.

After a long time I recognized that breaking the code at line 321 in CDVWKWebKitViewEngine.m got the app working constantly in the simulator which brought me adding a sleep timer in line 321:

- (id)forwardingTargetForSelector:(SEL)aSelector
    [NSThread sleepForTimeInterval:1.0];
    return _engineWebView;

That at least got the app starting without breakpoints in the simulator. However on the physical device it kept the white screen.

I will now go on debugging to spot another point. But any help or hints are highly appreciated.

What is expected to happen?

App should start correctly after splash screen.CDVWKWebKitViewEngine.m -> userContentController:didReceiveScriptMessage should be fired on every App start reliably.

What does actually happen?

userContentController:didReceiveScriptMessage is only fired on iPhone 11 Pro Simulator, iOS 13.3 when [NSThread sleepForTimeInterval:1.0]; is added in line 321 in CDVWKWebKitViewEngine.m:

- (id)forwardingTargetForSelector:(SEL)aSelector
    [NSThread sleepForTimeInterval:1.0];
    return _engineWebView;

Without adding the sleep line I encounter a white screen in 5 out of 10 cases in the simulator. userContentController:didReceiveScriptMessage is not fired in those cases.

On physical iPhone 11 Pro, iOS 13.3.1 the app launches constantly with a white screen after splash and userContentController:didReceiveScriptMessage is not fired - even if I set the sleep to 5 seconds.


Environment, Platform, Device

  • iPhone 11 Pro Simulator, iOS 13.3 (App starts after 1 sec sleep hack)
  • iPhone 11 Pro, iOS 13.3.1 (Still broken)

Version information


  • 9.0.0 (cordova-lib@9.0.1)
  • cordova-plugin-camera: 4.1.0
  • cordova-plugin-device: 2.0.3
  • cordova-plugin-dialogs: 2.0.2
  • cordova-plugin-file: 6.0.2
  • cordova-plugin-media-capture: 3.0.3
  • cordova-plugin-statusbar: 2.4.3
  • cordova-plugin-wkkeyboardfix: 1.0.1
  • cordova-plugin-wkwebviewxhrfix: 0.1.0

React: - onsenui: 2.10.8 - react: 16.8.6

XCode: 11.3.1 MacOS Catalina 10.15.4