Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » How to be really sure cloud is updated?
- gtoal
-
Scratcher
1000+ posts
How to be really sure cloud is updated?
I've released a version of Sokoban - a puzzle that is fiendishly difficult to solve and each level might take an hour or more. I am saving in the cloud the highest level that a user reaches, but every now and then it looks like it saved but in fact did not. (Confirmed by checking the Cloud Log.) For example I just completed level six and should have started the next time I launched the program on level 7 but in fact it started at level 5. The fact that it did successfully update the saved level to 5 earlier suggests that the logic of the level-saving code is OK, so I suspect I am suffering from the problem of Scratch quietly failing to update a cloud variable when there's a network glitch.
However my network seems fairly reliable - this is the only place that I'm seeing network problems, if that is indeed what is happening.
Is there any way to detect that a cloud update failed, and keep retrying until it works?
If anyone wants to check out the code it's at http://scratch.mit.edu/projects/32836744/ The cloud part of the code is based on a Leaderboard app by @Infernous.
(Btw I do have a bug in my code that I haven't fixed yet - I load the cloud data when you first start the program and then save it every time the player reaches a new level. What I forgot was that other users may be playing for an extended period too, and someone is going to write back their cache and lose someone else's updates. However at the moment there has only been one other player and I checked the Cloud Logs so I know that hasn't happened yet. This problem is easily fixed by reloading the cloud data just before saving it.)
thanks,
Graham
However my network seems fairly reliable - this is the only place that I'm seeing network problems, if that is indeed what is happening.
Is there any way to detect that a cloud update failed, and keep retrying until it works?
If anyone wants to check out the code it's at http://scratch.mit.edu/projects/32836744/ The cloud part of the code is based on a Leaderboard app by @Infernous.
(Btw I do have a bug in my code that I haven't fixed yet - I load the cloud data when you first start the program and then save it every time the player reaches a new level. What I forgot was that other users may be playing for an extended period too, and someone is going to write back their cache and lose someone else's updates. However at the moment there has only been one other player and I checked the Cloud Logs so I know that hasn't happened yet. This problem is easily fixed by reloading the cloud data just before saving it.)
thanks,
Graham
Last edited by gtoal (Nov. 11, 2014 06:06:41)
- TheLogFather
-
Scratcher
1000+ posts
How to be really sure cloud is updated?
One thing to note is that if you have more than one instance of your project open, only the most recently loaded one has cloud access - the previously loaded instance loses access as soon as you load another.
Is it possible you were playing on an instance that was ‘old’…?
But, yes, this is one of the most annoying aspects of cloudvars - you can't tell if they are really saving to the server, ‘cos your local copy of the var gets updated to the value you’ve just set it to, irrespective of what's happening with the cloud server.
If there are other users running a project, and you see cloudvars are being updated regularly (i.e. not by yourself), then you can tell you're connected ok. But if you're the only one on a project, there's really no way you can tell if your cloudvar changes are really getting saved. What's worse, if there *was* more than one user on the project, and you suddenly find that you're no longer seeing any updates from them, you've no way of knowing if that's because they just left (went to another page, quit browser, lost their ‘net connection), or if you’re the one who's no longer connected for some reason.
I'd really like to see some way in Scratch to inquire about cloud connection status - it would help considerably in certain situations.
Is it possible you were playing on an instance that was ‘old’…?
But, yes, this is one of the most annoying aspects of cloudvars - you can't tell if they are really saving to the server, ‘cos your local copy of the var gets updated to the value you’ve just set it to, irrespective of what's happening with the cloud server.

If there are other users running a project, and you see cloudvars are being updated regularly (i.e. not by yourself), then you can tell you're connected ok. But if you're the only one on a project, there's really no way you can tell if your cloudvar changes are really getting saved. What's worse, if there *was* more than one user on the project, and you suddenly find that you're no longer seeing any updates from them, you've no way of knowing if that's because they just left (went to another page, quit browser, lost their ‘net connection), or if you’re the one who's no longer connected for some reason.

I'd really like to see some way in Scratch to inquire about cloud connection status - it would help considerably in certain situations.
Last edited by TheLogFather (Nov. 11, 2014 08:55:26)
- gtoal
-
Scratcher
1000+ posts
How to be really sure cloud is updated?
One thing to note is that if you have more than one instance of your project open, only the most recently loaded one has cloud access - the previously loaded instance loses access as soon as you load another.
Is it possible you were playing on an instance that was ‘old’…?
That's a very likely possibility because I was doing exactly that at times to test whether the cloud var had been updated. That explains why it would work once but not a later time. Because I'd checked it, seen that it had worked, and by the very act of checking it, stopped it working the next time… A Heisenbug :-(
And it looks like if the second instance closes, the first instance doesn't pick up control again?
But, yes, this is one of the most annoying aspects of cloudvars - you can't tell if they are really saving to the server, ‘cos your local copy of the var gets updated to the value you’ve just set it to, irrespective of what's happening with the cloud server.
If there are other users running a project, and you see cloudvars are being updated regularly (i.e. not by yourself), then you can tell you're connected ok. But if you're the only one on a project, there's really no way you can tell if your cloudvar changes are really getting saved. What's worse, if there *was* more than one user on the project, and you suddenly find that you're no longer seeing any updates from them, you've no way of knowing if that's because they just left (went to another page, quit browser, lost their ‘net connection), or if you’re the one who's no longer connected for some reason.
I'd really like to see some way in Scratch to inquire about cloud connection status - it would help considerably in certain situations.
Thanks. This pretty much forces me to ignore the existence of cloud vars to record progress, and switch to one of those annoying schemes where you give the user a keyword after successful completion of a level, which they have to enter on the next visit in order to be able to resume from that point :-( With all the baggage that entails such as a large vocabulary file and a hash of the username so that every user gets a different set of keywords to open up each level, so they don't share them by posting them in the comments :-(
Perhaps restricting people like this this may seem like misplaced effort, and that I should just let people pick whatever level they want to skip to, but if you're familiar with Sokoban you'll know why it's important to go through each level in order, as they get progressively more difficult and build on tricks you discover as you work your way through them, By skipping ahead, players would get even more frustrated than they do by playing it in order and would very likely give up.
Thanks for the explanation. As always with Scratch it boils down to that one monumentally bad original design decision that users should never see a compile time nor a run time error message. It doesn't do learners any favours. Computers don't work that way, this choice just instills bad habits at an early age that will probably never be unlearned.
Graham
Last edited by gtoal (Nov. 11, 2014 15:49:49)
- TheLogFather
-
Scratcher
1000+ posts
How to be really sure cloud is updated?
Decided it was worth trying to throw in a suggestion for some way to check cloud connection…
(Oh, and no, once a new instance loads, your token is updated, and the token for the previous instance becomes invalid, and won't get restored if the new instance closes
)
(Oh, and no, once a new instance loads, your token is updated, and the token for the previous instance becomes invalid, and won't get restored if the new instance closes
)Last edited by TheLogFather (Nov. 11, 2014 17:48:36)
- Discussion Forums
- » Advanced Topics
-
» How to be really sure cloud is updated?



