LocalStorage resets randomly

0 favourites
  • 5 posts
  • 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

  • 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?

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)