Slow loading in applet

I'm currently investigating the possibilities to move Imperii to an applet and it works perfectly locally but when deploying on a remote server, the loading time increases a lot! And I don't mean the download time of the jar's itself but the loading of resources from the jars in the game.

I have successfully used applets with jme before without these huge loading times. So I am confused why I am getting them now.

The following is what I have located is slow when deployed:

  • Loading of particlessytems saved as .jme
  • Loading of geometry saved as .jme

    An example from the log:

    INFO: Model "City" loaded as resource stream in 457 mS. (locally)

    INFO: Model "City" loaded as resource stream in 8900 mS. (remotely)

    After loading, the game runs fine in normal speed.

    So what might be wrong? Probably something with loading of jme files but is there anything I must be extra carefull when loading from jar's downloaded from servers?

    I have tested both having resources in the same jar as the classes and separately.

    And I have tested using both getResource and getAsResourceStream, and the second is a little faster but not much.

    Thanks for reading


Woohooo im into the 100's :slight_smile:

Thanks matzon for that missing link - sounds obvious now you mention it, only ever needed to stop an applet at startup once before but as I had found a workaround never looked any further  :smiley:

Exactly where is the time spent?

In loading the model into jme or locating the resource?

It could be that the ResourceLocator uses more time when loading things in a applet.

I've tested with and without resource locator and it's the same. Although it might use it internally, I don't know?

After work today, I will try to narrow it down further. But it's a slow process since I cannot use a debugger in the deployed applet. (or?)

If you can specify classpath jars that are not located locally then you might be able to debug the slow loading times. As a crude fix to the issue, I would suggest reading the entire file, then wrap it as a ByteArrayInputStream and give it to the BinaryImporter.

Not sure if this was what you were after - but is possible to debug deployed applets ( I only know details for windows and eclipse so if you are on another OS you might have to do a bit of digging :slight_smile: ).

First you need to configure the applet runtime environment. Open the java control panel ( on Windows start->controlpanel->java ) - on the java tab in the java applet runtime settings area click view.

This lists all the installed java runtime versions. For the version you are using (actually I generally just set it for all versions) set the Java Runtime Parameters to :-

-Djava.compiler=NONE -Xnoagent -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

address can be set to any port you like if 8000 isnt available, but thats it.

Now from eclipse, create a remote debugging configuration (Run

Ah, thanks. I didn't know about that approach of debugging applets. My loading that is slowed is after user presses start on the menu button so it should work quite well then.

I can't test it right now since I will be away on vacation from tomorrow. But as soon as I can, I will give it a try.

I will also look into that ByteArrayInputStream wrapper, might be a solution.

Thanks both of you.

suspend=n <-- change to y, then you have all the time in the world