Hello Guest

JNLP and CPU usage issues

  • 15 Replies
  • 19329 Views
JNLP and CPU usage issues
« on: December 06, 2004, 11:46:26 »
Well, I've packed up a couple of my games in JNLPs, and at first thought all was just perfect. However, while my first game, which is not frame-rate dependant, runs fine, the second, which IS frame-rate dependant, ran very slow. I did some testing to discover that when I run them via a JNLP, the CPU ramps up to near 100%. The odd thing is though, that when I run them via a batch file, the CPU utilization is only around 20% and the game runs smooth as silk.

Anyone else ever see this problem? I've coded everything in Java 5.0 (1.5). I also made sure to use the exact same JARs for running the batch file as I did the JNLP. Is there a trick to this or something?

Also, on a side note, I like using JNLP to distribute my games that use lwjgl - it makes it much simpler. I noticed however, that many games (like AlienFlux) use a binary executable to launch the game. How do you do that?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

*

Offline princec

  • *****
  • 1898
    • Puppygames
JNLP and CPU usage issues
« Reply #1 on: December 06, 2004, 14:07:36 »
I have no idea why your games are suddenly using 100% CPU when launched via webstart - it's not normal.

As for launching via an exe - well, that's a simple JNI application that creates a Java VM, loads the game main class and executes main() on it. Dead easy to do. I'm going to root for Webstart again though for a bit. The exe is a last-ditch resort now.

Cas :)

*

Offline elias

  • *****
  • 899
    • http://oddlabs.com
JNLP and CPU usage issues
« Reply #2 on: December 06, 2004, 17:23:03 »
This is a long shot, but try adding this inside your <resources>:
Code: [Select]


<property name="sun.java2d.noddraw" value="true"/>


It should make sure that there's no ugly DirectX<->OpenGL interactions when AWT is used (by JWS). You could also try firing up a separate AWT window from the batch run to see if that makes a difference.

 - elias

*

Anonymous

JNLP and CPU usage issues
« Reply #3 on: December 06, 2004, 18:23:48 »
Unfortunately, that wasn't it. HOWEVER, you clued me into something else:

I'm setting sun.java2d.opengl and sun.java2d.translaccel both to true. Once I disabled those, I get the exact same high utilization issues from the command line like I do in JNLP.

So, does JNLP not allow those to be set for some reason? Can I override it somehow and set them anyway? I'll try out the property setting in the jnlp file and let you know.

JNLP and CPU usage issues
« Reply #4 on: December 06, 2004, 18:30:32 »
It looks like it's specifically the sun.java2d.opengl property. I can embed it into the program with the system.setproperty command, but jnlp won't recognize it. I also tried the "property name=" option in the JNLP, but it still won't enable it.

Any ideas? I could turn it off I suppose, but then I'd lose all of my acceleration in my game (since I'm using java2D with translucent images for sprites -- I'm using lwjgl for my sound only since I'm not an opengl guy).
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

*

Offline elias

  • *****
  • 899
    • http://oddlabs.com
JNLP and CPU usage issues
« Reply #5 on: December 07, 2004, 01:57:23 »
I'm afraid the only "safe" properties not ignored by Web Start 1.5 (previous version only recognized the heap size arg) are those listed in:

http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html

and those you use are not listed.

 - elias

*

Offline princec

  • *****
  • 1898
    • Puppygames
JNLP and CPU usage issues
« Reply #6 on: December 07, 2004, 05:53:46 »
That's incorrect. All system properties are recognised by Webstart. What aren't recognised are VM parameters (-X).

The problem is that Webstart itself may be causing the problem with its own GUI.

Cas :)

JNLP and CPU usage issues
« Reply #7 on: December 07, 2004, 10:11:34 »
Ugh. Well, I've got issues then.  :(

So, I guess here are my options:
1) Convert all my image assets to gif or transparent-only png, severly lowering image quality in the game.
2) Run the game via a command line/batch process (is there a windows-batch method I could use rather than a .bat file?) - although I'm still a bit curious as to how well supported the sun.java2d.opengl setting is.
3) Learn OpenGL and hit the programming block as hard as I can (just frustrating because I was so close to finishing I thought). I'm really quite clueless as to how to do graphics in OpenGL.

Any opinions on the best direction? (Or other options that I'm not thinking of?)

Any help would be appreciated.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

*

Offline princec

  • *****
  • 1898
    • Puppygames
JNLP and CPU usage issues
« Reply #8 on: December 07, 2004, 10:43:13 »
Do it with OpenGL. It's surprisingly easy. Just be aware that if you've got an AWT widgets or Swing that you won't really be able to use them any more...

Cas :)

JNLP and CPU usage issues
« Reply #9 on: December 07, 2004, 10:50:04 »
I actually ended up using only java2D calls and made all of my menus and things "in-game," so, theoretically, it should be an easy port. I'm studying the SpaceInvaders104 code right now from the lwjgl site.

I figured that if I really wanted to get serious about game development, I'd have to go there someday anyway. I'm just a complete n00b though. It even took me a while to implement lwjgl for sound, and I'm still not sure I understand all the buffer and initialization stuff. Nice thing about Java though, once you finish building a good framework, you don't have to worry about it anymore unless it's got bugs. I just hope I get it right the first time.  :?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

JNLP and CPU usage issues
« Reply #10 on: December 07, 2004, 13:34:53 »
"Alms... alms for the poor..."

Ok, believe it or not, I have a VERY simple port of my game going on OpenGL now (this is a big deal for me actually). I have two issues though:

1) I'm using the textureloader class from the SpaceInvaders source code. I'm not very excited about taking someone else's code. Is this ok?

2) None of my sprites are transparent anymore (they all have a black opaque box behind them). Is there a way to turn on translucency in OpenGL? (Come on, there's gotta be, right?)
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

JNLP and CPU usage issues
« Reply #11 on: December 07, 2004, 14:32:11 »
Ok, for the transparency, I had to add these to my initializer:

GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);

I can't believe it! I'm actually programming in OpenGL!  :P

But I am still concerned about using the textureloader from the spaceinvaders demo. Anyone see any license or anything for that code?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

JNLP and CPU usage issues
« Reply #12 on: December 07, 2004, 14:47:16 »
Quote from: "elias4444"
But I am still concerned about using the textureloader from the spaceinvaders demo. Anyone see any license or anything for that code?

it's in the header of java source :roll: (same license as lwjlg)

*

Offline princec

  • *****
  • 1898
    • Puppygames
JNLP and CPU usage issues
« Reply #13 on: December 07, 2004, 14:49:04 »
Texture loading code is so mind-bogglingly trivial it would be quite banal to actually enforce any kind of license on it anyway!

Cas :)

JNLP and CPU usage issues
« Reply #14 on: December 07, 2004, 14:51:40 »
Well, thank you guys SO much! I can't believe I'm actually doing stuff in OpenGL now!!!! I never thought it was possible. (BIG thanks to everyone who's worked on lwjgl!)

Now I'm off to experiment with lighting.  :wink:

Also, on a last note: anyway to change the window icon in the top left of the window when not in fullscreen mode? It's not as important, but would certainly be nice.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com