LocalStorage resets randomly

Bugs will be moved here once resolved.

Post » Wed Jun 28, 2017 2:32 pm

Problem Description
I thought I had gotten my save hi score to work, because it actually works quite nicely. For every second that passes, the score increases by 1. If the score is greater than hiscore than HiScore becomes Score.

And the HiScore saves, so it seems like its working fine. Even if I refresh the browser, close the browser and then restart, the HiScore returns as normal.

However sometimes at random the HiScore will reset. I have no idea why. Has this ever happened to anyone else? Perhaps it's just because its on "preview mode".

Attach a Capx
https://drive.google.com/file/d/0B637It ... sp=sharing

Description of Capx
adds 1 point to score every second
if score is greater than hiscore than hiscore becomes score

Steps to Reproduce Bug
    random
    I can say that it always happens after an hr

Observed Result
HiScore works fine even after resets and close browsers
Then after a random amount of time (approx > 1hr later) the HiScore will reset

Expected Result
The HiScore to remain

Affected Browsers
  • Chrome: (YES)
  • FireFox: (YES)
  • Internet Explorer: (YES)
  • Safari: (YES)

Operating System and Service Pack
Windows 10
iOS 10

Construct 2 Version ID
r244
B
4
Posts: 4
Reputation: 208

Post » Thu Jun 29, 2017 10:02 am

any ideas :(

***EDIT***
I have tried my project again after almost 24 hrs and the highscore remains saved and loaded fine. Very strange, because multiple times in the past it would reset for no reason and then work again.

***2nd EDIT***
For some reason it saves fine on Desktop now, (havent made any changes in the last 24 hrs), but on safari it no longer saves after closing the browser and restarting....

Can anyone suggest another way of saving and loading?
B
4
Posts: 4
Reputation: 208

Post » Thu Jun 29, 2017 11:18 am

It's entirely up to the browser if it remembers storage or not, this is not something C2 controls. As you describe C2's code is working correctly as it is able to restore data between browser sessions. If you are running low on disk space, the browser will periodically clear storage to avoid wasting disk space. So I think the browser is just cleaning up data on your behalf.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Thu Jun 29, 2017 1:09 pm

Ashley wrote:It's entirely up to the browser if it remembers storage or not, this is not something C2 controls. As you describe C2's code is working correctly as it is able to restore data between browser sessions. If you are running low on disk space, the browser will periodically clear storage to avoid wasting disk space. So I think the browser is just cleaning up data on your behalf.


Thanks Ashley, if I was to create a mobile game would this still happen?
B
4
Posts: 4
Reputation: 208

Post » Thu Jun 29, 2017 4:36 pm

I think storage in Cordova is more persistent, but in a browser on mobile, it probably uses the same policy as on desktop (automatically cleaning up if you run low on space).
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 0 guests