Results 1 to 9 of 9
  1. #1
    morello is offline Member
    Join Date
    Feb 2011
    Posts
    10
    Rep Power
    0

    Default Java applet strange performance problem

    I have a Java applet which does simple animation.

    For testing, I created a simple html page with an applet tag which referenced a local copy of the applet jar on my PC. It runs at a reasonable speed.

    Then I put the applet jar on a remote web server, and the html page (modified to reference the remote applet). Same browser, identical jar file, it gets downloaded and cached on my machine and runs locally.

    But it is 100 times slower. What was smooth animation becomes a picture which just jumps after a few seconds. This isn't a startup problem, it is a runtime problem.

    Does anyone know what could be causing this? How can the same jar file perform so differently, both are running from different folders on the same disk?

    The only thing I am wondering, the applet is not signed. I guess the local one is trusted but the remote one isn't. Could extra security checks be slowing it down? Is it likely to help if I self sign the applet?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,039
    Rep Power
    10

    Default Re: Java applet strange performance problem

    How are you loading your images? What happened when you signed the jar?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    morello is offline Member
    Join Date
    Feb 2011
    Posts
    10
    Rep Power
    0

    Default Re: Java applet strange performance problem

    The software doesn't use images. It plots animated graphs, drawn with java 2d.

    I tried signing the applet (self cert) and it is coming up with the standard warning dialog as you would expect. But it still runs just as slow.

    I am stumped by this at the moment - it is obviously possible for the browser to run the applet at full speed because that is what happens when I run the local copy. I can't figure out what the difference is with the remote version.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,039
    Rep Power
    10

    Default Re: Java applet strange performance problem

    When you run an applet, it downloads the jar to a temp folder and runs it from there. So it's still running locally.

    But without an SSCCE, we can't really help you other than to guess.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    morello is offline Member
    Join Date
    Feb 2011
    Posts
    10
    Rep Power
    0

    Default Re: Java applet strange performance problem

    Quote Originally Posted by KevinWorkman View Post
    When you run an applet, it downloads the jar to a temp folder and runs it from there. So it's still running locally.
    Yes I was pretty sure that was the case, which is why it is so confusing.Two copies of the same jar file, running in the same browser, consistently behaving differently. Will try to create a SSCCE

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Java applet strange performance problem

    Do you have code in a painting method override that attempts to communicate with the server?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    morello is offline Member
    Join Date
    Feb 2011
    Posts
    10
    Rep Power
    0

    Default Re: Java applet strange performance problem

    There is no communication with the server, aside from opening a server side XML file to set up the animation. That happens at startup, and the file is closed before the animation runs.

    I made an SSCCE, but of course it runs fine, doesn't show the same problem :(

    I was hoping I would ask here and find out this is a common problem that can be fixed easily. Looks like it is specific to the software I am working on (sadly a fairly complicated desktop app I am converting to an applet). Thanks for the suggestions.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Java applet strange performance problem

    If you have s simple version working OK then you might be stuck with the fun task of adding bits and seeing which part is causing the problem.
    The first thing I would look at, though, is that remote XML.
    I would lay good odds on that (since it's the only remote resource you are using) being the culprit.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    morello is offline Member
    Join Date
    Feb 2011
    Posts
    10
    Rep Power
    0

    Default Re: Java applet strange performance problem

    Some more information, perhaps it will ring a bell with someone. It looks like it is something to do with either TextLayout or FontMetrics.

    The problem is associated with some code which draws formatted maths expressions. They take around 0.5 sec or more to draw in the remote applet case, but far, far less for an applet hosted locally. This is hardly a problem for static diagrams, but when the diagram animates and tries to redraw the canvas 24 times a second it is wrecked.

    The only obvious difference between the maths expressions and ordinary text (which has no problem) is the use of TextLayout/FontMetrics to render the equation. Even a very simple expression "x" shows the problem.

    I will try to post back if I ever track this down. At the moment it is on the pile of "important but not quite as urgent as some other stuff".

Similar Threads

  1. Java Applet Strange Image Loading Problem
    By 1yuchen in forum Java Applets
    Replies: 36
    Last Post: 01-06-2012, 03:06 AM
  2. applet loading errors strange?!
    By newbie_jar in forum Java Applets
    Replies: 1
    Last Post: 11-08-2011, 06:35 PM
  3. Replies: 12
    Last Post: 07-25-2011, 04:25 PM
  4. Applet performance problem...
    By pmrenaud in forum Java Applets
    Replies: 0
    Last Post: 01-07-2009, 04:47 PM
  5. Java applet strange painting behaviour
    By sirdori in forum New To Java
    Replies: 1
    Last Post: 01-07-2009, 02:14 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •