updating.gif

jaynabonne
07 Sept 2012, 22:53
When playing online, sometimes out of the blue, I will suddenly see the "updating" image in the top right corner. I was curious what causes that to happen. I have seen it in other games I've played, and it happens quite it lot in the experimental stuff i was doing. :) But I've looked through the web player source, and I haven't found any references to it so far, short of that it is created and exists on the web page.

Is there something that is explicitly kicked off by code? If so, what can cause it to appear? Or is it that if the player gets "busy" for a certain amount of time, it automatically goes off? (As in, there is some sort of "deadman" code in place, where unless it gets disabled by the player, it starts displaying.)

sgreig
08 Sept 2012, 00:31
As far as I know, it doesn't appear erroneously. If it's displaying then the game is either loading something or "working."

jaynabonne
08 Sept 2012, 09:42
No, I didn't think it was erroneously. :) I figure it must be an indication of something real. More I was wondering what were the conditions when it appeared. As in, is it:

1) Something in the engine is deliberately invoking the graphic to appear (and if so, what), or
2) Does it appear more or less automatically when the game engine bogs down for whatever reason?

I'm trying to get an idea of performance, basically. When I first started seeing that graphic, especially when it would come up in the middle of a game, I wondered what the heck it was doing - was it loading stuff over the internet, for example? But now in my case, I would hope my small game would be entirely loadable and in memory, with no real large assets, and so when it still was coming up, it made me wonder what the mechanism was. Or, basically, what it all meant. :)

Ideally, I'd like to find a way to eliminate that, to smooth things out. If it's coming up a lot and means "this game is running slowly", then it could likely mean I need to optimize my code better. Or it could mean that what I'm trying to do isn't really possible online.

The Pixie
08 Sept 2012, 10:42
Does it load the game on the local PC? i assumed every time the player types a command, that goes to the server to get a response, and the updating icon appears if that is slow. I have a prett poor connection, so see it a lot.

jaynabonne
08 Sept 2012, 11:44
I'm not really sure. I would assume that the game file is loaded in its entirety (given that it's XML with no set order to the elements, and partially parsing XML is a real pain, and an element at the start of the file could reference something at the end). In my case, with the "breakout" demo, there wasn't even any user input. Just the code looping, drawing to the screen. And yet all sorts of the "updating" image, and the ball stopping and starting. I wasn't sure if something was kicking off bringing up the updating image, which made my game run erratically, or... my game runs slow, which was causing the updating image to appear. It's hard to determine yet which is cause and which is effect.

My assumption at this point is that, for some reason, the code runs slower in the browser, such that the updating icon kicks in since the game is just bogged down. If that is true, then I'd be curious to know if it's my code per se, or if some assumptions the web player is making in its main update loop about how a game is stuctured are horribly violated by what I'm doing. :) Or maybe my code needs optimization.

Alex
09 Sept 2012, 18:28
When you play a game online, all the game logic runs on the server. When you enter a command, that is sent to the server, the server processes it, and then sends the text output to the browser. The updating graphic appears automatically after a certain time has elapsed (something like 500ms) if the browser is still waiting for a response from the server.

In the case of your demo, you have a timer running which executes a script every second. The way timers work online is that the browser waits for the time to elapse, then sends a message to the server. The server then responds with the updated screen, and tells the browser to call again in one second. So this adds an additional delay which is why the game runs slower.

There's not much you can change in your code to speed this up. For the game to run well it would have to run entirely locally in the browser. It could do this if converted to JavaScript (something which I currently have as an internal beta - I'm not planning to make all games run in-browser though).

jaynabonne
10 Sept 2012, 09:14
I see. That's very informative, and explains a lot. Thanks for the details. :)

(And actually, it was worse - I was just looping, delaying for 1/10 of a second, all in the room entry function. But it would still need to hit the server to get the next screen image...)