12

Site is used on Samsung Galaxy Tab with the Gingerbread OS. Browsers used so far are the stock browser as well as Dolphin HD. Items in local storage seem to at random disappear when users go in and out of network coverage. Storage also seems to not be able to fully survive browser crashes or device restarts. Weird part is storage doesn't usually clear out completely, just a large number of items go missing. Anyone else heard of this problem or have any suggestions?

Edit: By local storage I mean,

localStorage["Key"] = value;

Retrived using:

localStorage.getItem("Key");

In every case, directly after adding to local storage, the site is able to retrieve and use the data. However, sometime after this usually after roaming or browser/tablet crashes, the data is no longer there. Everything I've found says local storage should persist, so I don't really know where to go from here.

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
jmease
  • 2,507
  • 5
  • 49
  • 89
  • 2
    Suggestion: Show some relevant code, so that others can verify it. – Rob W Nov 09 '11 at 22:44
  • The latest generations of mobile browsers tend to clear local storage at the same time cookies are cleared. Could that be what's happening? – Eric J. Nov 09 '11 at 22:45
  • 1
    Just a general question. Items added by localStorage["Key"] = values that are there throughout use of the site are suddenly not there any more at random times. Usually after roaming or after a browser crash. I've only been able to replicate it once, but several users per day run into it and causes quite a problem when it happens. Just wondering if this is a known issue and if other HTML5 offline storage methods are more reliable? – jmease Nov 09 '11 at 22:47
  • Code would be very helpful. Example of issue might be if the site is using transactions for bulk inserts and they aren't committed, that would explain lots of data suddenly going missing. – Geekswordsman Nov 09 '11 at 22:47
  • Cookies actually still seem to be intact every time. So probably not. – jmease Nov 09 '11 at 22:47
  • This is becoming actually quite a large problem. Anybody???? Are other forms of offline storage more stable? Indexed DB? – jmease Nov 11 '11 at 17:50
  • 1
    I suggest you to use WebSQL, although W3C had decided to use Index DB to replace WebSQL, the Index DB is not available on both Android and iOS, while the WebSQL is still available and used by many company as the offline storage. – Yu Jianrong Nov 19 '11 at 15:47
  • 1
    An important benefit of WebSQL than LocalStorage is: when the LocalStorage is full for this site, your new setting on the storage will be failed on iOS and there is no way en enlarge the storage. But if you use WebSQL on iOS, the user will be prompted to enlarge the offline database, when you create a database bigger than 5M, 10M, 25M and 50M. – Yu Jianrong Nov 19 '11 at 15:49
  • See http://stackoverflow.com/questions/8200646/is-local-storage-persistant, this guy is having a similar problem in Chrome. – Steven de Salas Nov 23 '11 at 17:38
  • Thanks for the info on WebSQL and Indexed DB. I've read a lot about those as well. I am hesitant to put the time into converting over though since the way this problem is manifesting almost seems like a compatibility problem in the browser. It may struggle with all forms of localized storage. I've contacted the browser's support, but they have been zero help. – jmease Nov 29 '11 at 14:40
  • Just to clarify what I meant by how it is manifesting it looks like browser compatibility. Out of the 60 or so users we have on the site (all accessing from the tablets), only 4 or 5 have even reported the issue. The only common theme I can find among them is that they all can say they had driven through areas where they were roaming. So 55 users with no issue tells me it's not something with the site or with the browser during normal use. Just some glitch that happens that wipes out the storage, seemingly tied to coverage. – jmease Nov 29 '11 at 14:51

1 Answers1

3

How about debugging this a bit further? Maybe your own code is somehow overwriting it? I am using localStorage/sessionStorage in PhoneGap and never had them disappearing...

Add the following event handler:

window.addEventListener("storage", function(e) {
   console.debug(e);
}, false);

Which will fire (and log to console, on desktop browser) every time the storage is accessed. You could also log more detailed info to be seen in your adb logcat (like the key being accessed!)

Have a look at this stackoverflow question for more details on Storage events.

Community
  • 1
  • 1
Leon
  • 4,532
  • 1
  • 19
  • 24
  • Thanks Leon. It's my fault for not updating the post. I've tried adding an event listener. Users are only using the site on mobile devices, so there is no console to write to. And since the listener doesn't fire for any events from that page, it's not proven useful. I figured out a way to get the listener to fire site wide, but it involved popups and is more than I want to put my users through. – jmease Nov 29 '11 at 14:47
  • there are some nice jscript logging utilities - like [log4javascript](http://log4javascript.org/index.html) that allow you also to log to a server (i.e. [AjaxAppender](http://log4javascript.org/docs/manual.html#ajaxappender)) that might be of help in debugging mobile issues like these... Hope this helps – Leon Nov 30 '11 at 08:47