WKWebView is the browser component Apple introduced in iOS 8 to replace UIWebView. It uses multi-process rendering, so page scrolling does not block image loading, crashes do not affect the main process, and memory usage is lower. After years of refinement, WKWebView is now stable and outperforms UIWebView in performance, stability, and user experience.
After the release of iOS 12, Apple began showing deprecation warnings for UIWebView APIs. By August 2019, apps using UIWebView received a warning on App Store submission, advising developers to switch to WKWebView.
On December 23, 2019, Apple announced that the App Store would stop accepting new UIWebView-based apps in April 2020 and stop accepting updates for existing UIWebView-based apps in December 2020.
mPaaS adapted for WKWebView in two phases to ensure H5 page stability during the transition:
-
Phase 1 (November 2019): The mPaaS baseline supports both UIWebView and WKWebView, with grayscale release for a gradual switch.
-
Phase 2 (March 2020): The mPaaS baseline removes all UIWebView code. All H5 services use WKWebView.
The mPaaS 10.1.60 baseline completed Phase 1. If you use the mPaaS H5 Container or miniapp components, upgrade to the 10.1.60 baseline (Upgrade the baseline) and switch to WKWebView (Use WKWebView).
Upgrade the baseline
If you use the mPaaS H5 Container or miniapp components, choose a baseline based on your app's release status.
-
For apps already listed on the App Store before April 2020: Upgrade to the 10.1.60 baseline, which supports grayscale release and rollback. 10.1.60 Official Release Upgrade Guide.
-
For new apps not yet listed on the App Store before April 2020: Use version 10.1.68, which removes all UIWebView code. Perform thorough regression testing before release. mPaaS 10.1.68-beta Upgrade Guide.
Use WKWebView
By default, the mPaaS container uses UIWebView to load H5 pages. You can enable WKWebView globally or through a grayscale release.
10.1.60 baseline
The 10.1.60 baseline includes both UIWebView and WKWebView, defaulting to UIWebView. Enable the global WKWebView switch to load all pages with WKWebView.
- (void)application:(UIApplication *)application afterDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//...
// Enable the global WKWebView switch
[MPNebulaAdapterInterface shareInstance].nebulaUseWKArbitrary = YES;
//...
}
After enabling WKWebView, check the User Agent (UA) of the H5 page. If the UA contains WK, the page is using WKWebView.
Rollback
After enabling WKWebView globally, the mPaaS framework provides immediate remediation to quickly roll back to UIWebView. Add a configuration switch in the real-time release component to restrict specific offline packages or URLs to UIWebView.
The Configuration key is h5_wkArbitrary. The Resource value format:
{
"enable": true,
"enableSubView": false,
"exception": [
{
"appId": "^(70000000|20000193)$"
},
{
"url": "https://invoice[.]starbucks[.]com[.]cn/"
},
{
"url":"https://front[.]verystar[.]cn/starbucks/alipay-invoice"
}]
}
The following table describes the configuration items.
|
Configuration item |
Description |
Notes |
|
|
enable |
Enables or disables WKWebView. |
Default: |
|
|
enableSubView |
Enables or disables WKWebView for webViews embedded in miniapps. |
Default: |
|
|
exception |
appId |
H5 pages in offline packages whose appIDs match this regex are excluded from WKWebView. |
Default: |
|
url |
H5 pages whose URLs match this regex are excluded from WKWebView. |
||
10.1.68-beta baseline
Version 10.1.68-beta uses WKWebView by default for offline packages and miniapps. Check the UA of the H5 page. If it contains WK, WKWebView is active.