Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Localstorage sometimes wrong #254

Open
mbaeurle opened this issue Jul 26, 2016 · 3 comments
Open

Localstorage sometimes wrong #254

mbaeurle opened this issue Jul 26, 2016 · 3 comments

Comments

@mbaeurle
Copy link

If port 12344 is ever in use when the app is (re)started, the wkwebview plugin will move on to port 12345, see startServer() in AppDelegate+WKWebViewPolyfill.m.

As the port number is used in the name of the copy of the localstorage, confusion starts if the port number is ever changed.
Effects seen by customers are no stored data in the app at all or the app is not continuing with the data from the last run, but using the localstorage from the run before, thus forgetting changes that the user has made.

Proof that this can happen is the existence of both /Library/WebSiteData/http_localhost_12344.localstorage and /Library/WebSiteData/http_localhost_12345.localstorage that I have seen on a customer's iPhone.

See copyLS() in MyMainViewController.m, which has this comment:
// TODO if the app is ever launched on a different port.. LS can't be loaded -- not worse than the previous implementation, but still
// TODO use the port, luke!

But it's not clear to me, what is the idea behind using the port in the file name in the first place?

Tests with iOS 10 Beta indicate that this is occurring quite frequently on iOS 10. I haven't been able to view any files/logs so far because iExplorer can't read iOS 10 devices yet.

This is a serious problem anyway because users may be getting wrong data, even though this only happens rarely. If this is more frequent on iOS 10 then it will be even more of a problem in the future.

@andreialecu
Copy link
Contributor

I'm seeing the same problem on iOS 10 with localstorage not being loaded at all. Not sure what is going on there.

One workaround that I'm starting to work on is to use the iOS keychain to store settings, or https://github.com/apla/me.apla.cordova.app-preferences

@kristfal
Copy link

kristfal commented Sep 5, 2016

In addition your issue @mbaeurle, iOS10 local storage will no longer store data between app launches. For now, I'd recommend the nativeStorage plugin, which works almost like a drop-in replacement for localStorage (it is async though, so you'll need to handle callbacks). Using nativeStorage will also resolve your issue.

@nicowenterodt
Copy link

nicowenterodt commented Oct 13, 2016

yip. I can confirm that. With iOS10 the localStorage seems to be cleared after the app restarts. I'm using IndexDB and WebSQL as an alternate storage-provider now.

https://github.com/localForage/localForage gives you a nice async API for this.

However the synchronous localStroage was a sleek way to store some sort of key/value -data with less effort. Looking forward to get this working again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants