Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

localStorage not being persisted in hybrid app in Android M42

In the latest release of ·Android System WebView (M42 42.0.2311.129)· there seems to be issues with localStorage in hybrid apps.

I've submitted a bug report but I am trying to find a workaround for objects not being persisted in localStorage.

This is taken from the bug report:

Steps to reproduce the problem:
1. Start hybrid app built with phonegap
2. In app, call javascript localStorage.setItem("m42bug","test for localstorage")
3. Through developer tools debugging confirm object has been stored: localStorage.getItem("m42bug")
4. Close app 
(swipe it away, force close it or restarting the device all cause the same)
5. Start app
6. In app, call javascript localStorage.getItem("m42bug")

What is the expected behavior?

localStorage.getItem("m42bug") should return the value "test for localstorage"

What went wrong?

localStorage.getItem("m42bug") returns null.

Object.keys(localStorage) indicate there is no key for m42bug

like image 565
dparnas Avatar asked Nov 01 '22 05:11

dparnas


1 Answers

Faced the exact same problem. For a workaround we store the localstorage data on the phone on exit from the app and restore it from there on app start. Works fine :) Hope it helps :)

like image 124
user2159842 Avatar answered Nov 11 '22 04:11

user2159842