andrewphorn / ClassiCube-Client

The applet used for classicube.net
34 stars 19 forks source link

Reduced memory pressure. Fixed #263. Added adaptive vsync. #300

Closed mstefarov closed 9 years ago

mstefarov commented 9 years ago

1) Memory pressure has been reduced by decreasing the amount of temporary objects. GC should trigger less often, resulting in fewer lag spikes. Here is a profiling record of a 3-minute walk through a 512x512x64 level: before and after optimizations.

2) Fixed ENV_SET_COLOR packets received during the level-loading process causing a NullPointerException. This fixes #263. PacketHandler now creates a Level object ("newLeveL" field) when LEVEL_INIT arrives, but does not set minecraft.level to that object until LEVEL_FINALIZE. Packet handlers should use this variable to set level settings during the loading process.

3) Made vsync adaptive. If actual framerate drops below 1/2 desired framerate, vsync will be turned off to improve responsiveness.