使用Webstart技术的新一代Java Applet时加载缓慢的问题
我通过 jnlp 指定的 webstart 技术使用小程序。问题是当小程序加载时,在某些时候它开始加载非常慢。
这是加载时 java 控制台的输出,当我说它变得更慢时:
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
这是 jnlp 的示例:
<?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>
这是我游戏的 jnlp,可以对其进行测试gemserk.com/games/discover-the-way/play/" rel="nofollow">此处。
我在不同操作系统的不同机器上尝试了不同的浏览器,问题仍然存在。
问题似乎出在从资源内部加载资产时,但仅在加载嵌入在浏览器中的小程序时发生,如果我从控制台调用 javaws,它可以正常工作。
我还有另一个游戏运行得很好,使用相同的 jnlp 模板此处。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哇。下载的 jar 包相当大。我知道您提到当您从控制台运行时它可以正常工作,但一般来说,您可能会考虑使用 JarJar 和 Pack200 到创建一个高度压缩的 JAR,它的下载速度应该比单独的 JAR 下载快得多。缺点是发布到一个库的单个更新将需要另一次完整下载,而不需要单独的 JAR。
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.
尝试关闭 codebase_lookup范围。
Try turning off the codebase_lookup parameter.