crosswalk-project / cordova-plugin-crosswalk-webview

Crosswalk WebView Cordova Plugin (UNMAINTAINED)
https://crosswalk-project.org/blog/crosswalk-final-release.html
Apache License 2.0
945 stars 350 forks source link

Gracefully remove Crosswalk from an app by migrating local storage #154

Open matthewlloyd opened 7 years ago

matthewlloyd commented 7 years ago

Now that Crosswalk has reached the end of its life, it would be great if this plugin provided a graceful way for developers to remove Crosswalk from their apps.

The main barrier to doing this is that any data stored by Crosswalk as cookies, in local storage, and so on, are lost when removing Crosswalk from the app.

Crosswalk performs this migration in the other direction, from the Android WebView to Crosswalk Chromium's storage, when it runs for the first time; see https://github.com/crosswalk-project/crosswalk/pull/3146.

It would be great if in this plugin, or in the plugin's documentation, we made it easy to perform the reverse migration, from Crosswalk's storage back to the Android WebView.

Slavezax commented 7 years ago

Just curious, you will go from Crosswalk to where? Is there any better alternatives that I don't know?

matthewlloyd commented 7 years ago

Back to standard Android WebView. The original purpose of Crosswalk was to bring the latest version of the Chromium browser to the Android platform because the original standard WebView would vary in features from device to device and often wasn’t up to date. More recent versions of Android now always include a good WebView based on a recent build of Chromium, so the Crosswalk project has been discontinued.

On Mon, Jul 31, 2017 at 6:44 PM Berkan Cesur notifications@github.com wrote:

Just curious, you will go from Crosswalk to where? Is there any better alternatives that I don't know?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview/issues/154#issuecomment-319217578, or mute the thread https://github.com/notifications/unsubscribe-auth/AB8ojPxW0_BzmFbsF4GGZbvzBmsdV76Wks5sTljkgaJpZM4Ol7lQ .

MBuchalik commented 7 years ago

@matthewlloyd Have you already compared the (current) Android WebView to Crosswalk? I can see a lot of performance differences here in my application (that can only be "fixed" by forcing hardware acceleration on a lot of elements through css). In my case, I am just wondering why there are so many differences between Crosswalk and Cordova's implementation of the default WebView? Is there any "secret" for creating the same experience without Crosswalk? I mean - Crosswalk must have used some other settings, otherwise the standard Android Webview should behave pretty much the same...

(Btw: I have tested it on an Android 5 device. The same problems occur when running in the Chrome app. On the other hand, the app runs smoothly on iOS and on Android with Crosswalk.) And sorry for "hijacking" your issue - thought it would be related thing to talk about :smiley:

matthewlloyd commented 7 years ago

This issue definitely isn't the place for such a discussion, but given that Crosswalk is no longer being actively developed, it's a moot point anyway. You can read more about the team's decision to stop developing Crosswalk here: https://crosswalk-project.org/blog/crosswalk-final-release.html

MBuchalik commented 7 years ago

So has nobody found a solution so far? I think there are a lot of developers who want to remove Crosswalk sooner or later. Not being able to do so without losing users' data can be a huge problem for some apps. Is there maybe a plugin I am missing? Btw: What will happen to the data when I remove Crosswalk? I cannot access it but will it still remain somewhere on the device? Or can I at least somehow delete it? Don't like the idea of having unnecessary data stored somewhere on the device...

matthewlloyd commented 7 years ago

Not that I'm aware of. I agree, it's going to be a problem for a lot of developers.

You can see how the data gets migrated from the webview to Crosswalk by reading this patch: https://github.com/crosswalk-project/crosswalk/pull/3146/files. It's as simple as moving a directory. That suggests the data will still be on the device after removing Crosswalk. So migrating the data back to the webview is probably as simple as moving a directory in the other direction, but there could be complications, e.g. what to do with the existing webview data, any potential differences in file structures or database schemas, and making sure the existing webview files aren't open or locked at the time the data is moved back.

MBuchalik commented 7 years ago

And here comes the problem to me as a hybrid app developer: I don't have enough experience (in writing cpp or similar) to create a plugin that could potentially do the steps to successfully migrate the data structures. Especially when trying not to accidentally delete something. :smile: Maybe, we are missing something... I have asked a question on the mailing list (https://lists.crosswalk-project.org/pipermail/crosswalk-help/2017-September/002468.html). Let's hope someone still reads it :smiley:

sarantist commented 7 years ago

i am really curious about how everyone is going to handle this situation.

For the app i work on i proposed to the team that we should make a release before removing crosswalk. In this release the local storage data will be migrated to the device storage. With this way our data are always going to be stored in the device, no matter what the webview or framework we ever use, even moving to something new like react native or even native, the data are going to be there for the user.

MBuchalik commented 7 years ago

On my project, I only need to migrate the localstorage (so no Cookies or similar). My idea was to migrate the existing SQLite database to the new Webview. Be careful: I haven't tested it completely (will do so maybe in a few months or so). When looking at the sandboxed storage dir (I think it is the applicationStorageDirectory you can use in the file plugin), there is a folder containig data stored by Crosswalk. From here, you have to navigate through a few folders and will eventually find a SQLite database file for the localstorage. At this point, I will

  1. Load a SQLite JS library helping me to extract the data
  2. Store this data in the new localstorage (simply by using localStorage.setItem)
  3. Delete the folders that aren't needed anymore (to free some space)

I am not sure if this approach will work. In my case (for my application) I haven't found a better solution so far but it looks like this could solve the problem...

dpa99c commented 7 years ago

https://github.com/dpa99c/cordova-plugin-crosswalk-data-migration

Add it to your app update after removing the Crosswalk plugin and it should migrate the data (local storage, WebSQL, IndexedDB) back to the system webview.

It's far from thoroughly tested, but probably best to let you guys break it and report issues than for me to test it forever before releasing it.

MBuchalik commented 7 years ago

@dpa99c This is truly amazing! 👍 👍 👍 I was thinking about using a JS solution (as mentioned above) but this definitely looks like the better approach. Maybe, your plugin should be highlighted somewhere on the Crosswalk Website, their Twitter page or similar? I hope that some of the Crosswalks developers still read this and can do so. Don't think we are the only ones who need to migrate their data :smile: (And: The more tests, the better...)

fredgalvao commented 7 years ago

@dpa99c I cannot stress how important it was that someone capable took the initiative to provide a solution to this. Thank you very much. I also think that, someone that can still post to the crosswalk project's twitter or blog, could take a look at your plugin and maybe share it on those mediums is deemed proper.

matthewlloyd commented 7 years ago

@dpa99c, this is really super - thank you so much! The detailed instructions you provide are truly valuable also. What a fantastic contribution to the community :)

kirillgroshkov commented 6 years ago

We are going to try the suggested plugin and then I'll report back here if it worked for us.

Currently I have one concern - race condition. In our code when check very early if we have certain things in localStorage. Plugin documentation says that the plugin does the job and then restarts the WebView. I wonder how to make sure that plugin has finished the job BEFORE we start to read from localStorage (and expect things to be there).

But we'll try and see...