X
Tap here to go to the mobile version of the site.

منتدى الدعم

Local Storage is not stored value.

Posted

firefox 67.0.3 (android) firefox 68.0b14 (android) (opera 52.4.2517.140781 (android))

Local Storage is not stored value. Wrote a simple example. It shows the current value of 'LS'. Went clicked in the monitor. The value of 'LS' has changed . Closed the browser - opened and the value 'LS' is not preserved.

<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="index, follow" name="robots"> <meta content="width=device-width, initial-scale=1.0" name="viewport"> <meta content="" name="copyright"> <meta content="" name="keywords"> <meta content="localstprage" name="description"> <title>localstoragetest</title> <style> *{margin: 0px; padding: 0px;} #iphone, #android{font-size: 28px;} #del{width: 50px; height: 50px; float: right; background-color: green;} </style> <script> window.addEventListener('click', function(e) // срабатывает при загрузке страницы БЕЗ CSS { "use strict"; var id = e.target.id; var iphone = document.getElementById("iphone"); var cur_LS = localStorage.getItem("test"); if (cur_LS === "123") {localStorage.setItem("test","ABC");} if (cur_LS === "ABC") {localStorage.setItem("test","123");} if (cur_LS === null) {localStorage.setItem("test","ABC");} if (id === "del") {localStorage.removeItem("test");} cur_LS = localStorage.getItem("test"); iphone.textContent = "set_new = "+cur_LS; }); window.addEventListener('DOMContentLoaded', function() // срабатывает при загрузке страницы БЕЗ CSS { "use strict"; var android = document.getElementById("android"); var cur_LS = localStorage.getItem("test"); android.textContent = "read "+cur_LS; }); </script>

read
new
DEL_LS

firefox 67.0.3 (android) firefox 68.0b14 (android) (opera 52.4.2517.140781 (android)) Local Storage is not stored value. Wrote a simple example. It shows the current value of 'LS'. Went clicked in the monitor. The value of 'LS' has changed . Closed the browser - opened and the value 'LS' is not preserved. <!DOCTYPE html> <html lang="ru"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="robots" content="index, follow"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="copyright" content=""> <meta name="keywords" content=""/> <meta name="description" content="localstprage"/> <title>localstoragetest</title> <style> *{margin: 0px; padding: 0px;} #iphone, #android{font-size: 28px;} #del{width: 50px; height: 50px; float: right; background-color: green;} </style> <script> window.addEventListener('click', function(e) // срабатывает при загрузке страницы БЕЗ CSS { "use strict"; var id = e.target.id; var iphone = document.getElementById("iphone"); var cur_LS = localStorage.getItem("test"); if (cur_LS === "123") {localStorage.setItem("test","ABC");} if (cur_LS === "ABC") {localStorage.setItem("test","123");} if (cur_LS === null) {localStorage.setItem("test","ABC");} if (id === "del") {localStorage.removeItem("test");} cur_LS = localStorage.getItem("test"); iphone.textContent = "set_new = "+cur_LS; }); window.addEventListener('DOMContentLoaded', function() // срабатывает при загрузке страницы БЕЗ CSS { "use strict"; var android = document.getElementById("android"); var cur_LS = localStorage.getItem("test"); android.textContent = "read "+cur_LS; }); </script> </head> <body> <div><span id="android">read</span></div> <div><span id="iphone">new</span></div> <div id="del">DEL_LS</div> </body> </html>
Quote

Additional System Details

Installed Plug-ins

no plugins installed

Application

  • User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36 OPR/60.0.3255.170

More Information

Question owner

revealed new patterns that behave the same in 'opera' and 'firefox' in these versions. If you close the first tab and then the browser data is saved. Or if you refresh the page after changing the data, the data is also saved.

revealed new patterns that behave the same in 'opera' and 'firefox' in these versions. If you close the first tab and then the browser data is saved. Or if you refresh the page after changing the data, the data is also saved.
Was this helpful to you?
Quote
ecc521 0 solutions 6 answers

Helpful Reply

I was able to reproduce the behavior using Firefox Beta 68.1 on Android 6.0.1. As stated, this only shows up if Firefox is swiped off or force stopped. If I had to guess at the issue, I would guess that Firefox is caching changes to localStorage while on mobile to reduce the number of disk writes, and when Firefox is suddenly closed, it loses those cached changes.

I was able to reproduce the behavior using Firefox Beta 68.1 on Android 6.0.1. As stated, this only shows up if Firefox is swiped off or force stopped. If I had to guess at the issue, I would guess that Firefox is caching changes to localStorage while on mobile to reduce the number of disk writes, and when Firefox is suddenly closed, it loses those cached changes.
Was this helpful to you? 1
Quote
ecc521 0 solutions 6 answers

Helpful Reply

I think I have found the issue:

It appears that Firefox caches localStorage writes, and will flush them either after 5 seconds or when other conditions are met. You can see the criteria written in the localStorage code at the gecko-dev repository.

As would be expected, I am unable to reproduce this bug if I wait 5 seconds before closing Firefox.

I believe this could be fixed if Firefox flushes to disk when it detects the app is no longer fully focused. I don't do that much with C++ and Android though, so I wouldn't be the one to tell you.

I think I have found the issue: It appears that Firefox caches localStorage writes, and will flush them either after 5 seconds or when other conditions are met. You can see the criteria written in the localStorage code at the [https://github.com/mozilla/gecko-dev/blob/8478c8b076a13af9ac5b29ff677c1f4fea2a7ed6/dom/tests/browser/browser_localStorage_e10s.js#L12 gecko-dev repository]. As would be expected, I am unable to reproduce this bug if I wait 5 seconds before closing Firefox. I believe this could be fixed if Firefox flushes to disk when it detects the app is no longer fully focused. I don't do that much with C++ and Android though, so I wouldn't be the one to tell you.

Modified by ecc521

Was this helpful to you? 1
Quote

Question owner

ecc521 said

I think I have found the issue: It appears that Firefox caches localStorage writes, and will flush them either after 5 seconds or when other conditions are met. You can see the criteria written in the localStorage code at the gecko-dev repository. As would be expected, I am unable to reproduce this bug if I wait 5 seconds before closing Firefox. I believe this could be fixed if Firefox flushes to disk when it detects the app is no longer fully focused. I don't do that much with C++ and Android though, so I wouldn't be the one to tell you.

thank you for finding a solution together. and Yes, You're right! If you wait about five seconds. That data is saved.

My suggestions to the developers to make this interval one second. Other browsers do not have this problem.

''ecc521 [[#answer-1236439|said]]'' <blockquote> I think I have found the issue: It appears that Firefox caches localStorage writes, and will flush them either after 5 seconds or when other conditions are met. You can see the criteria written in the localStorage code at the [https://github.com/mozilla/gecko-dev/blob/8478c8b076a13af9ac5b29ff677c1f4fea2a7ed6/dom/tests/browser/browser_localStorage_e10s.js#L12 gecko-dev repository]. As would be expected, I am unable to reproduce this bug if I wait 5 seconds before closing Firefox. I believe this could be fixed if Firefox flushes to disk when it detects the app is no longer fully focused. I don't do that much with C++ and Android though, so I wouldn't be the one to tell you. </blockquote> thank you for finding a solution together. and Yes, You're right! If you wait about five seconds. That data is saved. My suggestions to the developers to make this interval one second. Other browsers do not have this problem.
Was this helpful to you?
Quote
jscher2000
  • Top 10 Contributor
8638 solutions 70669 answers

vipmaster-05 said

ecc521 said
I think I have found the issue: It appears that Firefox caches localStorage writes, and will flush them either after 5 seconds or when other conditions are met. ... I believe this could be fixed if Firefox flushes to disk when it detects the app is no longer fully focused.

My suggestions to the developers to make this interval one second.

One of you could file a bug here: https://bugzilla.mozilla.org/

''vipmaster-05 [[#answer-1236449|said]]'' <blockquote> ''ecc521 [[#answer-1236439|said]]'' <blockquote> I think I have found the issue: It appears that Firefox caches localStorage writes, and will flush them either after 5 seconds or when other conditions are met. ... I believe this could be fixed if Firefox flushes to disk when it detects the app is no longer fully focused. </blockquote> My suggestions to the developers to make this interval one second. </blockquote> One of you could file a bug here: https://bugzilla.mozilla.org/
Was this helpful to you? 1
Quote

Question owner

jscher2000 said

vipmaster-05 said
ecc521 said
I think I have found the issue: It appears that Firefox caches localStorage writes, and will flush them either after 5 seconds or when other conditions are met. ... I believe this could be fixed if Firefox flushes to disk when it detects the app is no longer fully focused.

My suggestions to the developers to make this interval one second.

One of you could file a bug here: https://bugzilla.mozilla.org/

done, hopefully correctly all the issued)

Bug 1565612 The value is not stored in 'Local Storage'. If after changing the value do not wait 3-5 seconds. That is, set a new value and quickly close the browser. New local storage data will be lost.

''jscher2000 [[#answer-1236717|said]]'' <blockquote> ''vipmaster-05 [[#answer-1236449|said]]'' <blockquote> ''ecc521 [[#answer-1236439|said]]'' <blockquote> I think I have found the issue: It appears that Firefox caches localStorage writes, and will flush them either after 5 seconds or when other conditions are met. ... I believe this could be fixed if Firefox flushes to disk when it detects the app is no longer fully focused. </blockquote> My suggestions to the developers to make this interval one second. </blockquote> One of you could file a bug here: https://bugzilla.mozilla.org/ </blockquote> done, hopefully correctly all the issued) Bug 1565612 The value is not stored in 'Local Storage'. If after changing the value do not wait 3-5 seconds. That is, set a new value and quickly close the browser. New local storage data will be lost.
Was this helpful to you?
Quote
اطرح سؤالا

You must log in to your account to reply to posts. Please start a new question, if you do not have an account yet.