-
Notifications
You must be signed in to change notification settings - Fork 467
WKWebView: Inability to update on actual iPhone, though Simulator works #85
Comments
This occurs whether manually calling |
Understood, will try to reproduce it on my device. |
Yes, it seems the problem is with |
@nikDemyankov First off: this is just pure awesome stuff. |
@nikDemyankov FYI My issue is currently the same, but I can't even restart the app and get the new resources - we just get a blank page after an update is made. |
@nikDemyankov Confirmed manual update in simulator without WKWebView. |
@hussfelt thanks. Not sure at the moment. I just need to sit down and check what is wrong and how it can be fixed. It's more the timing issue for me. But now I'm starting to plan, what to be done in the next release, so will work on that one soon. |
@nikDemyankov tell me where to pour the 🍺 ! |
I think it has something to do with the bug in WKWebView - https://issues.apache.org/jira/browse/CB-10237 . Although, it does work fine on emulator (both iOS 8 and 9), but it doesn't reload the page automatically on the real device (iOS 9). It just silently ignores reload request and that's it. Will keep digging. |
@nikDemyankov <3 Thanks! You are plain awesome. 🎅 |
@nikDemyankov Could a fix be to use some sort of local proxy server for those requests? Something like this: https://github.com/shazron/CB-8838/tree/master/plugins/cordova-labs-local-webserver |
@Manduro Yes, that could help. There is another WKWebView plugin, which uses that approach (or something similar). The trick is to make it work with external www folder. And to restart it, when update is installed. I just don't want to make things more complicated then they are already... |
@nikDemyankov I've looked into that plugin as well, but it is for pre cordova-ios 4 and won't be supporting it as the new I understand you don't want it any more complicated, but I do think that WKWebView is very important to support as it comes with lots of benefits. |
@Manduro that's true :) |
@nikDemyankov has there been a resolution to this? All files except for index.html update on iOS9 devices. I was a day away from pushing to the app store and ran into this "stale index.html" issue. Let me know if we are close. Thanks a bunch for an amazing plugin! ☀️ |
@jboothe Am I understanding you correctly that everything works in combination with the WKWebView except it does not update the index.html file? In that case this could clearly be a documented tradeoff - I'd live with having to update the app through AppStore for index.html fixes until we have a solution for the core issue... |
@jboothe no, unfortunately at the moment I couldn't fix that. Not sure even how to do it correctly. There is an idea from @Manduro to use local web server for showing pages. Haven't tried it yet, but it scares me a little: kind of hack-ish way... @hussfelt No, the problem is not with the documentation. Index page is updated properly without WKWebView. The problem is that for each new release plugin creates new folder (more details here). On simulator WKWebView has no problem with changing working directory after the update. But on a real device - it does. If it started showing files from |
Perhaps we have different issues since my app does not employ the cordova-plugin-wkwebview-engine. To be clear, I experience the following on iOS 9 devices but not in the emulator: When following Nik's 6 steps here, all but the index.html page update and updates only occur when closing and reopening the app. Oddly, performing a |
nikDemyankov wrote: “On simulator WKWebView has no problem with changing working directory after the update. But on a real device - it does. If it started showing files from /2015.12.01-12.01.33/www/ - it's not gonna switch to/2015.13.01-15.01.00/www/ until the full restart.” Hi nik.
Parameters Discussion In fact if you think about it, it’s not just that an update will fail to show up until the user performs a full restart, it’s also true that the unpacking of the bundled www inside the app to the initial hotcode push external www folder won’t be used until after a full restart. So, the fix needs to happen in two places. On startup and on update. And the only fix I can think of, aside from re-instantiating the wkwebview with the new updated file url and all plugins, is to always use the same well-known folder to load files from. I guess that means on an update, you would have to delete the current files that are being “served” and copy the new ones into the same folder. If the user was doing something important, I’m thinking that could lead to some data corruption / race conditions. But if you could inform the user that this was about to happen and ensure that they weren’t doing anything important during an update, it might be passable. Not sure about rollbacks and update errors…. I forked your excellent repo and implemented this hack. Works on an ios 9.2 ipad and Cordova 5.0.0 with Cordova ios 4.0.1 and cordova-plugin-wkwebview-engine 1.0.2 and cordova-hot-code-push-plugin 1.2.5 |
Hi @bluoma ,
Actually, the first versions of the plugin was doing exactly that :) But I had to move to "new release -> new folder" scheme because of the problems you described, plus:
So, moving to "new release -> new folder" scheme solved some nasty problems and made plugin much more stable. But, unfortunately, brought problem with the wkwebview. Didn't know about it, when migrated to the new scheme... |
@nikDemyankov @bluoma Couldn't this be fixed by putting the release folders inside a common chcp folder? Or does the readAccessURL disallow subdirectories as well when it references a directory? Another possibility might be to put the index.html's in their own folder, using index-{release}.html files, with some sort of solution for file references inside index.html. |
@Manduro "does the readAccessURL disallow subdirectories as well when it references a directory?" Now that I re-read my original post, I think I should have said that this behavior of wkwebview, not to allow reloading from a different readAccessURL, is undocumented behavior. Maybe someone should file a radar:// on Apple to correct the docs or allow reloads from a different folder. ?? |
Basically, they are all already inside common chcp folder. But maybe setting |
Here's Telerik's overview of the good, bad & ugly of Cordova WKWebView Plugin. ...might provide some insight into solving this problem. |
@nikDemyankov just noticed that if the content folder is created under the application's tmp/ directory, this error doesn't occur. So if you edit HCPFilesStructure.m and change the 3rd line below to reference "tmp/":
I don't see the error: Sandbox: com.apple.WebKit(829) deny(1) file-issue-extension and reloads happen fine onResume. Seems like WebKit2's sandbox rules need fixing. I don't know if using /tmp is really a workable solution. FYI, I also tried "Documents" and "Library/caches" and those both fail for me. |
@bluoma thanks for the info, will check it out. But |
Good news everyone: seems like some sort of solution has been found. Currently all release folders are stored like this:
When new update comes - new By default, wkwebview doesn't allow to switch to another folder. In the CDVWKWebViewEngine.m WK plugin set's So, the fix is to set it pointing to Thanks @Manduro for pointing in the right direction. Now I need to figure out, how to set this |
@nikDemyankov Great news! Seems like an easy solution :) |
Hi @nikDemyankov. First thanks for the awesome work ! |
Hi, @MarcBT. Thanks :) Yes, that is correct: for Telerik WKWebView there, probably, should be another fix. As we discussed in #127 - it stopped working after I switched from setting I will try to upload in the dev branch fix for wkwebview today, and then will start looking into telerik version. |
Ok, thanks for the fast answer. Have a good day ! |
… we need to set the correct readAccessURL, or WKWebView is not gonna load our updates. Work in progress. #85
…on the presence of the cordova-plugin-wkwebview-engine. #85
Okey, |
Released in v1.3.0. CHCP plugin should now work with |
@nikDemyankov I can only use Teleriks wkwebview, can is it possible to ship a fix for that as well? |
So this is not working for me, at least not with https://github.com/driftyco/cordova-plugin-wkwebview-engine This is the first WkWebview Engine, with a XHR polyfill hack, that allows remote and local XHRs with a breeze. I don't know if its possible for you to fix this. I have 1.4.0 installed, the simulator will update, but not the real device. |
First question: no, I did not. Cause it does not work for my use case (no local XHR on file:/// possible = useless, as I can't use any framework) Second: No, I will try and give you a feedback. |
@hirbod hi, it seems that we are using same technologies... :) |
@cvaliere no, I did not. I am sticking to the simulator currently, so "real time testing" on a real device is not possible currently. Lauching with or without Xcode did not change anything @nikDemyankov In my case, it's not a big deal, as I am developing inside simulator 99% of time, but it would be a nice to have. |
After deploying a new version, the simulator can update itself without restarting the app (without any issues), but for a physical iPhone, the following error occurs:
If I manually shut down the app and re-open it, it will have the updated code.
Tested on an iPhone 6 Plus, iOS 9.2 - same specs for Simulator.
One possible wrench thrown in the mix might be that we're using
cordova-plugin-wkwebview-engine
.The text was updated successfully, but these errors were encountered: