SaveState isn't working in Chrome
Monkey Forums/Monkey Programming/SaveState isn't working in Chrome
| ||
Not sure if this is a bug, if I'm doing something wrong, or if SaveState is just useless for HTML5. Simple exampleImport mojo Class myApp Extends App Method OnCreate() SaveState("Hello.") End End Class Function Main() New myApp End Function When I run this (HTML5) and check Chrome's localstorage, I get the following in Local Storage>>localhost: key: .mojostate@... value: Hello. If I then completely shut down Chrome, and reopen it, the saved data is gone. Surely this can't be right??? I'm just installing Visual C++ to see if I fare any better using GLFW target for prototyping but still, I'm not sure this thing with HTML5 is expected behaviour as SaveState really needs to be persistent. Is that not the whole point of it? |
| ||
You're not clearing cache, temporary files etc. when Shutting down Chrome, either with chromes own built in util or some other 3rd party one used in chrome or on your system? Sounds stupid but just thought I'd chime in with the obvious first. |
| ||
Nope, that was the first thing I checked. |
| ||
Save/LoadState works fine on Chrome for me. I've been using it for a fair while. |
| ||
A couple of thoughts. * Are you seeing any other local-storage files in your user folder? I have files from various google sites, amazon, twitter, gawker and a bunch of others, so if you regularly browse with Chrome and there's nothing in there then you might want to take another look at what Amon mentioned. * Are you testing the Load without restarting the Monkey HTTP server? If you restart the server it will pick a new port to run on and this will change the local storage file that is used. In other words, a save, restart and load won't work. |
| ||
Dave, I don't see the point of targeting HTML5. Just because Monkey can, doesn't make it a great idea, especially for any kind of commercial reality. As a Flash developer your are more likely to earn a living. As iOS developer you typically will struggle to ever pay off your hardware investment. As an HTML5 developer you have your head in the clouds so not really relevant. As an android developer, oh please... For anyone trying to do more than one of the above, I would suggest even greater odds of failure rather than success. |
| ||
I'm not, skid. I'm working on an iOS version of my game (released today on BFG for PC/Mac) but I can't really get along with programming on a Mac. I'm trying to do the bulk of it in Windows and JungleIDE, and I'm using HTML5 for that. Maybe you're right though, I should just choose a different target for prototyping. |
| ||
Hmm, it is nice and quick to compile for and would be good to sort out issues with Chrome, and you can always just use a browser that does work... If Chrome does save when game is served from file:/// and not http://localhost then you can configure trans to not use mserver which can make dev even snappier. The config is in monkey/bin. |
| ||
and you can always just use a browser that does work... Which one would that be? I always thought Chrome was the best option for HTML5 stuff. |
| ||
I would recommend using the flash target. |
| ||
Aye, but then I have to mess about converting all my OGG files to... whatever Flash supports (MP3?). |
| ||
you can always just use a browser that does work All the major browsers work in my testing on Windows, assuming that you don't have some setting that clears the saved data and that you don't change the URL between runs (e.g. by restarting the HTTP server). |
| ||
Hi, Works OK here. Have you 'bypassed' MServer? If so, SaveState (and some other features) will not work on some browsers (at least Chrome). You must use MServer in order to emulate documents being served from a 'domain' to get full html5 functionality. |
| ||
I just tested on my laptop and got the same issue there, too. I've also noticed that LocalStorage>>Localhost seems to be 'per tab'. I.e. after I run my game, I open a new tab, then developer tools for that tab, and my savestate is not there either. And no, there's nothing else in localstorage. [edit] Have you 'bypassed' MServer? Um... I'm not even sure what that means so I'll assume not! |
| ||
Hi, Muddy_shoes has a point - each re-run of MServer will create an entirely new 'domain' (as port will be different) that local storage will bind to - ie: shutdown/restart mserver and local storage will probably disappear as the app will be being served from a different domain. Also, how do you 'check Chrome's localstorage'? Are you sure this isn't referring to local storage for the current document? |
| ||
Well, it doesn't disappear from the system, it's just not related to the new domain. Eventually it will result in odd behaviour because the server will return to an old port and pick up an old state string (we possibly need some extra features in the MServer to handle this). Judging from what Gfk is saying, he's looking at the local storage through the resources tab in the Chrome dev tools. This works fine for me, even if I switch browser tabs. I really suspect that it's a privacy setting issue (options->under the bonnet->content settings) or possibly a Windows permissions issue if Chrome isn't writing a file at all in "C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default\Local Storage" or whatever the equivalent is in his flavour of Windows. |
| ||
Muddy_shoes has a point - each re-run of MServer will create an entirely new 'domain' (as port will be different) that local storage will bind to - ie: That was it! It works fine provided I don't change the port number. Is there any way to force a given port number? It would be handy for testing. Judging from what Gfk is saying, he's looking at the local storage through the resources tab in the Chrome dev tools Yep. I still don't get why its always empty. Ho hum... or possibly a Windows permissions issue if Chrome isn't writing a file at all in "C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default\Local Storage" Just checked - the files are there, but they are not what I expected them to contain, as I can't actually see the contents of my saved state anyway as its in some stupid SQLite format.Ta for the help! |
| ||
youre not supposed to close the server app until you are done programming for the day |
| ||
Then what am i meant to do tomorrow? |
| ||
You could try renaming the file. |
| ||
Could do but it'd be much simpler if mserver could be set to use a fixed port number. does having it random even serve any useful purpose? |
| ||
Isnt the source inlcuded for mserver? Just change the random port setting bit, rebuild in BlitzMax, replace the original binary! Dabz |
| ||
I dunno. easy fix if it is! |