My problem: The ionic app I'm developing is horribly slow, after finding out UIWebView is the culprit I'm looking for ways to speed it up, with WKWebView being the most promising solution.
What my project looks like: When setting up a sample ionic project (http://ccoenraets.github.io/ionic-tutorial/install-ionic.html for example) with the current Cordova 4.1.0 CLI (i'm using Ionic 1.2.4) UIWebView is used as default. However, since Cordova 4, the new and faster WKWebView is supported out-of-the-box and can be forced, at least in iOS 9 (cordova 4 supports WKWebView).
The plugin I used & configured:
via cordova plugin add cordova-plugin-wkwebview-engine
the support is added for the iOS platform (9.3 right now). When this plugin is added and properly configured in the config.xml with
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
What I tried so far:
In the terminal ionic build ios
, then build succeeds, and when installing the app via XCode 7.3 on OS X El Capitan 10.11.3 in the console log the Using WKWebView
message is printed but then, right after the splashscreen, the app container fades into a white screen of death. As soon as I remove that plugin, UIWebView is used and the app works as expected.
Alternative: replacing the original plugin wkwebview-engine-localhost with one with integrated localhost, works. As I understood, the WKWebview should be supported by cordova and ionic right out of the box, without having to rely on some "labs plugin" with an integrated server, which was developed to support iOS 8 which I don't need. I understand that WKWebView has quite some limitations compared to the old UIWebView, especially when it comes to handling file://
statements known issues, but there for sure must be someone out there who got Ionic + Cordova WKWebView working without all the hassle I had, right? There must be better ways to achieving a simple speed improvement for the webview.
I tried probably every solution, config, plugin combination, cordova cli version downgrade (minimum being 4.0.0 for WKWebView support), clearing caches and resetting and restarting of my device, new install and readding of platforms and update of cordova, npm, various plugins, but all of them either didn't help at all except for the apache labs plugin above or seemed like a huge mess that didn't change anything.
When remote debugging the ios app on the device via my local Safari, I can see in the elements tree, that the body tag stays either empty, or a simple "ng-view" placeholder for an angular element is shown. Am I correct that there must be a problem with the retrieval of files/angular scripts through the way cordova via WKWwebView handles it?
Note: the app itself works fine, either with ionic serve
or ionic emulate ios
, only when deploying to a real device over XCode (since ionic run ios
doesn't work, but that's a different story) the white screen appears.
Any help is very much appreciated, as it seems to me I have to either use the localhost+wkwebview plugin or let the users suffer from poor speed.
Thanks a lot!