graphics hiccups and class preloading

Have you ever noticed that the first time you drag a piece after opening
VASSAL, the drag is choppy and slower to start than all subsequent times?
When doing profiling last night to find the Labeler bug solved in svn3981,
I found the reason for it: Starting a drag requires several classes which
aren’t used anywhere else, so they’re not loaded prior to the first drag.
The “hiccup” you see when you start your first drag is three or four
classes being loaded, as is the “hiccup” which happens the first time you
do a drop.

Loading the classes needed for drags and drops is too slow to let it
happen lazily, because then the very first drag that the user does will
never be smooth. This doesn’t give a good first impression. One way around
this is to preload these classes (in particular, MovementReporter and
KeyBuffer) while the module is being loaded—the time to load a few more
classes during module loading is hardly noticeable, and anyway the user
isn’t expecting split-second response time at that point.

This raises the question of class preloading in general. I’m sure there
are other classes which would benefit from preloading. It might be worth
adding some code to GameModule which is called at module or game load-time
where we give a list of classes to preload.

Good idea. You could throw it in GameModule.build().

rk

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Rodney Kinney”:

It can’t go there. GameModule.build() is abstract.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake Joel Uckelman:

I put it in a static block in PieceMover, since that keeps it near other
relevant code.

J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)