views:

532

answers:

2

Hi,

[UPDATE: I forgot to add that this 30 sec. freezing problem only happens the first time I try to load a file from the server. Subsequent loads are very quick. Maybe some strange reverse DNS lookup? I am hosting on Google's appengine.]

I started a little project recently called http://www.chartle.net which is build around an applet.

Startup time is an important factor in the user's experience of an applet. I collect statistics and am shocked that I find often very long startup times (factor 50 to 100 higher then necessary)

The applet starts in 1-3 seconds depending on the speed of your computer and connection. Still for some users it takes up to 100 sec.

I have mixed results from my own tests. Mostly it is very fast but sometimes freezes the browser for a long time and the Java console doesn't tell me why. Best guess is, that it stalls when loading a saved chart.

Please help me figuring this out - best test by opening an already saved chart (click on one of the 'create' links at http://www.chartle.net/gallery)

Cheers, Dieter

+2  A: 

This is generic help rather than specific for your demo (which loaded fine for me in a few attempts).

Freezing applets

In the JDK bin directory there is a very handy programme called jstack. Refresh your browser window until it crashes and then run:

jstack *process_id*

This will give you the stack trace of any frozen Java process. If Java is not a separate process then you can use the browser's process (eg for Opera).

The following few problems were/are common for me:

  1. I reccommend you use invokeLater rather than invokeAndWait on the init method (although you can't do this if you use start/stop methods)
  2. Opera's custom java plugin acts very poorly...
  3. Deadlocks caused by synch blocks and invokeAndWait's

Slow applets

Possibly the browser is fetching resources from the server, unable to use the jar file?

Pool
Thanks but I already new those best practices. When I load a saved chart at startup it has to get that file from the server. Maybe delays here are caused bt some weird reverse DNS lookup. I have no clue so far.
Dieter
Hmmm, have you thought a profiler? YourKit has a 15 day trial and plugs into applets quite easily. You should be able to see which line is causing the hang.
Pool
+1  A: 

It may be that only the old plugin causes these problems. That means basically all people running on OSX and other users with Java prior to 1.6_update_10.

So, I would really appreciate people with such setups to watch their Java console and describe the first startup behaviour.

Cheers, Dieter

Dieter