You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "BBlashko (via GitHub)" <gi...@apache.org> on 2024/08/01 00:19:44 UTC
[PR] (ios) Adds a routine to flush WkWebView diskcache when the bundle ver… [cordova-ios]
BBlashko opened a new pull request, #1451:
URL: https://github.com/apache/cordova-ios/pull/1451
…ion changes
<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:
http://cordova.apache.org/contribute/contribute_guidelines.html
Thanks!
-->
### Platforms affected
- ios
### Motivation and Context
<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->
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
<!-- Describe your changes in detail -->
In the AppDelegate.m file I have added a routine to clear the `WKWebsiteDataTypeDiskCache` for the domain from the `Bundle ID`, and `localhost`. This cache needs to be flushed because it latches on to previous `js, html, css, etc` files from a previous `.ipa` installation. These cached files include the `cordova.js` and `cordova_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:
```
Module branch-cordova-sdk.Branch does not exist.
```
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
<!-- Please describe in detail how you tested your changes. -->
Our QA engineer had an instance of the application stuck in this state. The Error:
```
Module branch-cordova-sdk.Branch does not exist.
```
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
- [*] I've run the tests to see all new and existing tests pass
- [*] I added automated test coverage as appropriate for this change
- [*] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
- [*] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
- [*] I've updated the documentation if necessary
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] (ios) Adds a routine to flush WkWebView diskcache when the bundle ver… [cordova-ios]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue commented on PR #1451:
URL: https://github.com/apache/cordova-ios/pull/1451#issuecomment-2288146518
I wonder if an easier/better fix would be to prevent the local web content from getting cached at all (since it's already getting loaded from the device itself)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] (ios) Adds a routine to flush WkWebView diskcache when the bundle ver… [cordova-ios]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue commented on PR #1451:
URL: https://github.com/apache/cordova-ios/pull/1451#issuecomment-2299551087
I _think_ what we'd need to do is explicitly set a cache policy on the `NSURLRequest` that is created when we load a URL into the `WKWebView`: https://github.com/apache/cordova-ios/blob/3a426fd37d478fb8ee93d6de613e55888c4fa02b/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m#L334
By default, that's going to use "default protocol cache behaviour", which is documented here: https://developer.apple.com/documentation/foundation/nsurlrequestcachepolicy/nsurlrequestuseprotocolcachepolicy?language=objc
We might want to set the policy to `NSURLRequestReloadIgnoringLocalCacheData` and test if that solves the problem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] (ios) Adds a routine to flush WkWebView diskcache when the bundle ver… [cordova-ios]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1451:
URL: https://github.com/apache/cordova-ios/pull/1451#issuecomment-2262184451
## [Codecov](https://app.codecov.io/gh/apache/cordova-ios/pull/1451?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 78.35%. Comparing base [(`d8ebfb3`)](https://app.codecov.io/gh/apache/cordova-ios/commit/d8ebfb387b4bd92da28cf6d4c5b11772c4b1d7c7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`99a44db`)](https://app.codecov.io/gh/apache/cordova-ios/commit/99a44db3437dccad615a2d12b32ccda8d667033c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #1451 +/- ##
=======================================
Coverage 78.35% 78.35%
=======================================
Files 16 16
Lines 1825 1825
=======================================
Hits 1430 1430
Misses 395 395
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cordova-ios/pull/1451?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] (ios) Adds a routine to flush WkWebView diskcache when the bundle ver… [cordova-ios]
Posted by "BBlashko (via GitHub)" <gi...@apache.org>.
BBlashko commented on PR #1451:
URL: https://github.com/apache/cordova-ios/pull/1451#issuecomment-2299718869
I created a new pull request with the updated. Since it was a completely different approach I figured a new branch and new pull request was the best approach.
https://github.com/apache/cordova-ios/pull/1471
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] (ios) Adds a routine to flush WkWebView diskcache when the bundle ver… [cordova-ios]
Posted by "BBlashko (via GitHub)" <gi...@apache.org>.
BBlashko commented on PR #1451:
URL: https://github.com/apache/cordova-ios/pull/1451#issuecomment-2299536389
> I wonder if an easier/better fix would be to prevent the local web content from getting cached at all (since it's already getting loaded from the device itself)?
Ya that would make sense to me 🤔
Could you point me in a bit of a direction as to where `cordova-ios` initializing the `WKWebView`? so i can see if I can put some no cache configuration on it? I'm a bit inexperienced with Native iOS. I understand the `AppDelegate`, and that initializes the `MainViewController`, but where does the framework initialize the `WebView`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] (ios) Adds a routine to flush WkWebView diskcache when the bundle ver… [cordova-ios]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue commented on PR #1451:
URL: https://github.com/apache/cordova-ios/pull/1451#issuecomment-2316616166
Closing to close this PR in favour of getting #1471 merged in.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [PR] (ios) Adds a routine to flush WkWebView diskcache when the bundle ver… [cordova-ios]
Posted by "dpogue (via GitHub)" <gi...@apache.org>.
dpogue closed pull request #1451: (ios) Adds a routine to flush WkWebView diskcache when the bundle ver…
URL: https://github.com/apache/cordova-ios/pull/1451
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org