(ios) Adds a routine to flush WkWebView diskcache when the bundle ver… #1451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ion changes
Platforms affected
Motivation and Context
This Pull Request adds a routine to the Boot of cordova-ios so that we can flush diskcache in the WkWebView. There is a problem with iOS where the diskcache aka .js, html, and css etc files are cached between .ipa installs.
There is no issue for this at this time, I was discussing it with Norman Breau in the Slack Space
Description
In the AppDelegate.m file I have added a routine to clear the
WKWebsiteDataTypeDiskCache
for the domain from theBundle ID
, andlocalhost
. This cache needs to be flushed because it latches on to previousjs, html, css, etc
files from a previous.ipa
installation. These cached files include thecordova.js
andcordova_plugins.js
files. I know this because I added hacks into these files, but they were not registered on the target production application.The main problem this addresses is removals of Cordova Plugins. Where the cached cordova_plugins.js thinks that it needs to load a removed plugin, but since the plugins www directory was removed it doesn't exist.
An example error message is as follows:
Now I cannot confirm at this time, but it does indicate that with this cached files, that any additions to cordova_plugins.js may not be loaded at runtime.
I want to mention that this problem is extremely hard to reproduce in local environments. It needs to be on device, and it needs to be an update to an already installed application in production. Eg. I have 3.72.0 on my device, a new 3.73.0 version is released with removed/updated plugins, then this case can happen it is not guaranteed to happen for all users.
Testing
Our QA engineer had an instance of the application stuck in this state. The Error:
This error was thrown everytime they booted the application, where the UI was stuck on the Splashscreen.
Updating to the latest .ipa (with these changes in the PR) and booting, the user was able to get "unstuck". However, it's not a perfect solution because while the cache did get flushed, it didn't immediately repopulate it, and the user had to reboot the app. On second boot after this fix was introduced the user was able to boot the application successfully.
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)