Tuesday, June 17, 2008

That performance problem

While beta haven't been very popular, it did helped me. One comment I kept receiving was the poor performance. Not the server (it's doing surprisingly well) but the client. Well I found the bottleneck...

Back when the game was still in alpha, I never had any performance problems. There was probably near a hundred cows running around in about 4-5 zones. That was before I completed the characters' creation system.

At first, when you created a character, you were selecting an avatar and that was it. The new characters' creation system added the possibility to chose a body, face, suit, hat and hairs.

All layers were dropped on top of each other as background images in 5 DIV tags. Background images are needed to switch the view of the character (walking left, right, up and down). The problem is that background images aren't very good for performance. I'm sure there's a nice explanation somewhere about this...

So I did a small test and removed everything but the body layer, leaving only one background image per avatar (players and NPCs) and the performances were back where they were in alpha. Just like PNG files were slowing down the whole thing, too many background images creates a huge bottleneck.

So to fix this problem and still allow full character's customization, I'll have to merge all layers in every possible ways so that each avatar on the screen contains only one background image. That's a lot of files but it looks like it's the only way to do it.

Ah, the joy of web development...

1 Comment:

bonder said...

You could have an image handler that takes a character id and uses that to look up the composite body type and either grab the image out of the cache, or generate it and put it in (and return it!).