1

I am using applets through webstart technology, specified by a jnlp. The problem is when applet is loading, in some point it starts to load really slow.

Here is an output of java console when loading, when I say it become slower:

09:10:34.085 [Thread-15] INFO  c.g.r.d.ClassPathDataSource - loading stream classpath://assets/images/ball_animation.png
network: Conectando http://acoppes-laptop.local/prototipos/discoverthename-latest/resources-0.0.1-SNAPSHOT.jar con proxy=DIRECT
09:10:34.099 [Thread-15] INFO  c.g.r.d.ClassPathDataSource - loading stream classpath://assets/images/block_crack_animation.png
network: Conectando http://acoppes-laptop.local/prototipos/discoverthename-latest/resources-0.0.1-SNAPSHOT.jar con proxy=DIRECT
09:10:34.107 [Thread-15] INFO  c.g.r.d.ClassPathDataSource - loading stream classpath://assets/images/block_crack_animation.png
network: Conectando http://acoppes-laptop.local/prototipos/discoverthename-latest/resources-0.0.1-SNAPSHOT.jar con proxy=DIRECT
09:10:34.115 [Thread-15] INFO  c.g.r.d.ClassPathDataSource - loading stream classpath://assets/images/block_crack_animation.png
network: Conectando http://acoppes-laptop.local/prototipos/discoverthename-latest/resources-0.0.1-SNAPSHOT.jar con proxy=DIRECT
09:10:34.125 [Thread-15] INFO  c.g.r.d.ClassPathDataSource - loading stream classpath://assets/images/block_crack_animation.png
network: Conectando http://acoppes-laptop.local/prototipos/discoverthename-latest/resources-0.0.1-SNAPSHOT.jar con proxy=DIRECT
09:10:34.134 [Thread-15] INFO  c.g.r.d.ClassPathDataSource - loading stream classpath://assets/images/block_crack_animation.png
network: Conectando http://acoppes-laptop.local/prototipos/discoverthename-latest/resources-0.0.1-SNAPSHOT.jar con proxy=DIRECT

This is an example of how jnlp looks like:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+"
    codebase="http://www.gemserk.com/prototipos/discoverthename-release/"
    href="launch-applet.jnlp">
    <information>
        <title>Discover The Name - Ludum Dare 19</title>
        <vendor>Gemserk</vendor>
        <homepage href="http://www.gemserk.com" />
        <description>arielsan's game entry for Ludum Dare 19</description>
        <offline-allowed />
    </information>
    <security>
        <all-permissions />
    </security>
    <resources>
        <j2se version="1.6+" />
        <jar href="main-0.0.1-SNAPSHOT.jar" />
        <jar href="resources-0.0.1-SNAPSHOT.jar" />
        <jar href="game-0.0.1-SNAPSHOT.jar" />
        <jar href="logback-classic-0.9.17.jar" />
        <jar href="logback-core-0.9.17.jar" />
        <jar href="slf4j-api-1.5.8.jar" />
        <jar href="core-0.0.9-SNAPSHOT.jar" />
        <jar href="google-collections-1.0.jar" />
        <jar href="commons-io-1.4.jar" />
        <jar href="guice-2.0.jar" />
        <jar href="aopalliance-1.0.jar" />
        <jar href="cglib-2.2.jar" />
        <jar href="asm-3.1.jar" />
        <jar href="resourcesmanager-core-0.0.9-SNAPSHOT.jar" />
        <jar href="commons-0.0.9-SNAPSHOT.jar" />
        <jar href="slickmodule-0.0.9-SNAPSHOT.jar" />
        <jar href="slick-274.jar" />
        <jar href="jnlp-1.2.jar" />
        <jar href="lwjgl-2.6.0-GEMSERK.jar" />
        <jar href="jinput-2.6.0-GEMSERK.jar" />
        <jar href="resourcesmanager-slickmodule-0.0.9-SNAPSHOT.jar" />
        <jar href="animation-0.0.2-SNAPSHOT.jar" />
        <jar href="vecmath-1.3.1.jar" />
    </resources>

    <resources os="Windows">
        <nativelib href="lwjgl-2.6.0-GEMSERK-natives-win.jar" />
        <nativelib href="jinput-2.6.0-GEMSERK-natives-win.jar" />
    </resources>

    <resources os="Linux">
        <nativelib href="lwjgl-2.6.0-GEMSERK-natives-linux.jar" />
        <nativelib href="jinput-2.6.0-GEMSERK-natives-linux.jar" />
    </resources>

    <resources os="Mac OS">
        <nativelib href="lwjgl-2.6.0-GEMSERK-natives-mac.jar" />
        <nativelib href="jinput-2.6.0-GEMSERK-natives-mac.jar" />
    </resources>

    <applet-desc name="arielsan's game entry for Ludum Dare 19"
        main-class="org.newdawn.slick.AppletGameContainer" width="800" height="600">
        <param name="game" value="com.gemserk.games.discoverthename.Game" />
    </applet-desc> 

</jnlp>

That is a jnlp of my game, it could be tested here.

I have tried different browsers on different machines on different OS, and the problem persist.

The problem seems to be when loading assets from inside a resource, but only happens when loading the applet embedded in the browser, if I call javaws from console, it works without problems.

I have also a another game working great, using the same jnlp template here.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
arielsan
  • 418
  • 2
  • 4
  • 11
  • I am using logback for logging, I found if I remove the logback.xml (for configuring the appenders, etc) the applet loads fast. It is a first workaround, but I want to know why this happens exactly. – arielsan Jan 11 '11 at 17:08

2 Answers2

1

Wow. That's a pretty large download of jars. I know you mentioned it works ok when you run from the console, but in general, you might consider using a combination of JarJar and Pack200 to create a single, highly compressed JAR which should download much faster than separate JAR downloads. The downside is that a single update published to one library will require another full download, which with separate JARs would not be required.

Nicholas
  • 15,916
  • 4
  • 42
  • 66
  • Thanks for the advice, however that's not the problem right now, try the second game I posted, it works great, download fast, etc, all games are using pack200. The problem is with the first one, it become really slow when loading and it is based on the same template the second one uses, but only if you play it as an applet, if you try the webstart, it works great too. – arielsan Dec 31 '10 at 13:18
  • Does the applet sandbox invoke some additional jar verification that webstart does not ? – Nicholas Dec 31 '10 at 14:19
  • I tested this link (http://blog.gemserk.com/games/discover-the-way/play/) after clearing the cache, and the applet loaded up pretty quickly. (Using Ubuntu 8.1/64, Chrome Browser and Java 1.6_14). But that's all relative. If it is useful, I can send you the java console log. One other thing that occurred to me is that it might help to specify in the applet def. (Shot in the dark) – Nicholas Dec 31 '10 at 14:43
  • First of all, thanks for trying it and thanks for the answer, it could be useful to see that log yes. I don't understand which is the difference between both games, they have the same configuration. About the parameter, I am using next generation applets, I believe that means always runs on a separated jvm -> http://java.sun.com/developer/technicalArticles/javase/newapplets/ – arielsan Dec 31 '10 at 23:27
  • About separated jvm, here is explained better: http://download.oracle.com/javase/6/docs/technotes/guides/jweb/applet/applet_execution.html – arielsan Dec 31 '10 at 23:29
0

Try turning off the codebase_lookup parameter.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433