I have a Swift application in which a WKWebView is implemented. This integrates my PWA. Through the PWA, a lot of data is loaded, which, with the help of a ServiceWorker (Workbox), is also stored locally on the device/app. This works wonderfully so far! However, when the user has really loaded a lot of data via the serviceworker (> 1 GB), the Swift application, or more precisely the WebView, takes a very long time to start (about 20-30 seconds). To me, it seems as if iOS is trying to load all the data into the ram or make it directly available. Unfortunately, this is a very unsatisfying user experience, and there were also devices that completely crashed.
I initialize the WebView as follows:
let config = WKWebViewConfiguration()
let userContentController = WKUserContentController()
config.userContentController = userContentController
if #available(iOS 14, *) {
config.limitsNavigationsToAppBoundDomains = true;
}
config.preferences.javaScriptCanOpenWindowsAutomatically = true
let webView = WKWebView(frame: calcWebviewFrame(webviewView: container, toolbarView: nil), configuration: config)
It definitely lies with the websiteDataStore, because when I include the following code additionally, the WebView appears immediately.
config.websiteDataStore = WKWebsiteDataStore.nonPersistent()
Unfortunately, then of course I no longer have a cache...
Does anyone have an idea on how to accelerate the DataStore or the initial loading of the WebView with large amounts of data in the websiteDataStore?