Wednesday, January 30, 2008

Random performance loss...

Went to bed around 2 a.m. last night trying to figure out why our framerate would drop to 30 fps randomly when the game was running on a perfectly. Every other module was commented out in the code except for the map drawing and map coordinate updating loops and we found that we'd still get a jitter.

Since we count on XNA to time our loops perfectly we get smooth movement by increment/decrement the x, y value whenever we want to move. If a draw pass is missed and the game updates twice then the position will jump two pixels, something we thought was very noticeable (considering that we are working on a very small scale). We tried pretty much everything to try and slim down the functions but it never fixed the problem... then we stumbled on Shawn Hargreaves's blog and his explanation on random slowdowns.

Our conclusion, based on his explanation of the GameTime class, is that the random framerate drop (for only a single frame every 100-200 frames) is caused by garbage collection. Gah...

On a good note I managed to make a GUI that I'm pleased with, check 'er out!


No comments: