I found some debug code that was executing in the last release build, causing significant slowdown. Fixing that, along with some tweaks for the new graphics code, has improved performance significantly. But there are also a few changes you could make that could be the difference between getting 60fps and 10fps.
You can play the latest release here.
The game monitors it’s own framerate and adjusts output quality to improve low framerates – currently just by decreasing the stage quality and reducing the amount of smoke things generate. When I test performance or profile, I disable this auto-degradation, and max out the game speed to +5.
Here’s an example of the top 10 lines of my profiler output in the release player. This test ran at 60fps.
12345678910 760x [ 6.109ms]=[ 4643ms] 34% non-frame:REMAINDER ***1135x [ 0.912ms]=[ 1035ms] 7.5% Box2d.Step:REMAINDER ***269472x [ 0.003ms]=[ 808ms] 5.9% Graphic.Update:REMAINDER ***35759x [ 0.013ms]=[ 473ms] 3.4% Graphic.UpdateCache:REMAINDER ***244094x [ 0.002ms]=[ 461ms] 3.3% Graphic.ApplyStateWhileDirty:REMAINDER ***109574x [ 0.004ms]=[ 397ms] 2.9% Thing.RenderCycle:REMAINDER ***112615x [ 0.004ms]=[ 395ms] 2.8% RenderMachine.UpdateVisual:REMAINDER ***198934x [ 0.002ms]=[ 368ms] 2.6% Graphic.Cycle:REMAINDER ***112615x [ 0.003ms]=[ 346ms] 2.5% RFX.ApplyToGraphic:REMAINDER ***79742x [ 0.004ms]=[ 294ms] 2.1% Flash_Graphic.ApplyState:REMAINDER ***
* “non-frame:REMAINDER” is the time flash spends not in my code – either idle or doing internal, mostly graphicy stuff I assume.
Huge FPS Hit: The Debug Flash Player
The “debug” version of Flash Player really doesn’t like something I’m doing in Jetpack. In the level “Pit of Chaos”, I get 55fps in the release player, and 13fps in the debug player. Music playback is also especially slow in this mode.
Here’s the profiler output in the debug player with music on. In my test level, this ran at 26fps.
12345678910 56x [33.911ms]=[ 1899ms] 18.5% mod:mixer ***191x [ 4.702ms]=[ 898ms] 8.7% non-frame:REMAINDER ***65544x [ 0.01ms]=[ 683ms] 6.6% Graphic.Update:REMAINDER ***27606x [ 0.018ms]=[ 484ms] 4.7% Thing.RenderCycle:REMAINDER ***321x [ 1.34ms]=[ 430ms] 4.1% Box2d.Step:REMAINDER ***28282x [ 0.015ms]=[ 422ms] 4.1% RFX.ApplyToGraphic:REMAINDER ***28292x [ 0.014ms]=[ 386ms] 3.7% RenderMachine.UpdateVisual:REMAINDER ***20635x [ 0.017ms]=[ 347ms] 3.3% Thing.CycleManualPhysics:REMAINDER ***59017x [ 0.005ms]=[ 321ms] 3.1% Graphic.ApplyStateWhileDirty:REMAINDER ***47883x [ 0.006ms]=[ 295ms] 2.8% Graphic.Cycle:REMAINDER ***
Small FPS Hit: Scaling the Game
If you play the game scaled or full screen (via browser zoom, or a plugin like Flash Game Maximizer), there will be a performance hit because of the scaling overhead. On the same level, my performance dropped to 52fps when scaled a bit, and 38fps when scaled to full screen height.
With the game scaled, and running in the debug player with music on, my test ran at 19fps.
Note: The final game will not have either of these issues, because it will not use an external Flash Player, and can set the monitor resolution to 800×600.