JDK-6754990 : Applet.getImage is slow
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u3
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows
  • CPU: x86
  • Submitted: 2008-10-01
  • Updated: 2017-05-25
  • Resolved: 2017-05-25
Related Reports
Relates :  
Description
From forum:
http://forums.java.net/jive/thread.jspa?threadID=47066&tstart=15

The API documentation for Applet.getImage says:
This method always returns immediately, whether or not the image exists.
When this applet attempts to draw the image on the screen, the data will be loaded.
The graphics primitives that draw the image will incrementally paint on the screen.

This is not true with Java Plug-in 1.6.0_10-rc2, as shown in the applet below.
It has been tested with Java Plug-in 1.6.0_01 and Java Plug-in 1.6.0_10-rc2.
The applet has been compiled with jdk1.6.0_03 and run in IE 6.0.2900.5512 SP3
on Windows XP SP3.
The tests were made using a dial-up connection, the ouput shows 9 sec for
getImage to return. Even on a slow connection, it should return immediately.
Really inconvenient! 


import java.applet.*;
import java.awt.*;
import java.awt.image.*;

public class GetImageBug extends Applet implements ImageObserver
{
   String image1Name = "image1.jpg";
   String image2Name = "image2.jpg";
   String image3Name = "image3.jpg";
   String image4Name = "image4.jpg";

   public void init()
   {
      new GetImageThread(this, image1Name).start();
      new GetImageThread(this, image2Name).start();
      new GetImageThread(this, image3Name).start();
      new GetImageThread(this, image4Name).start();
   }

   public boolean imageUpdate(Image img, int  infoflags,
      int  x, int  y, int  width, int  height)
   {
      if ( (infoflags & ImageObserver.ALLBITS) != 0 )
         return false;
      return true;
   }
}

class GetImageThread extends Thread
{
   Applet applet;
   String imageFileName;

   GetImageThread(Applet applet, String imageFileName)
   {
      this.applet = applet;
      this.imageFileName = imageFileName;
   }

   public void run()
   {
      long time0 = System.currentTimeMillis();
      Image image = applet.getImage(applet.getCodeBase(), imageFileName);
      System.out.println("getImgage(" + imageFileName + ") took " +
                               (System.currentTimeMillis()-time0) + " millis.");
      applet.prepareImage(image, applet);
   }

}

Comments
(Closed WNF) No plans to fix in JDK 7. If there's a remaining issue of concern with >= JDK 8 please file a new JBS issue. If there's a key concern about JDK 7, please contact Java SE Client Sustaining (and file a new JBS for that concern).
25-05-2017

- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

These are all approved for deferral to JDK 9 so you can update the FixVersion to state JDK 9. Kind regards, Mathias
29-08-2013

These are all approved for deferral to JDK 9 so you can update the FixVersion to state JDK 9. Kind regards, Mathias
29-08-2013

These are all approved for deferral to JDK 9 so you can update the FixVersion to state JDK 9. Kind regards, Mathias
29-08-2013

Converted "8-client-defer-candidate" label to "8-defer-request" by SQE' OK.
15-08-2013

*This is anti-deferral criteria list*: - P2 -------------- Engineering's Criteria ------------------------------------- - tck-red labeled - conformance labeled - P3 regressions reported/labeled against jdk8 - findbugs, parfait, eht labeled bugs - CAP <1 year reported - netbeans <1 year reported Victor ----------------- SQE's OK --------------------------------- Yes, we are ok with that thanks, Mikhail
15-08-2013

EVALUATION The likely reason is that both URLImageSource and SunToolkit.createImage() attempt to open connection. Perhaps this can be done later on. We should try to do this asyncronously if possible as even with fast network connection it will cause DNS lookup and this may have noticeable sideeffect in startup and responsiveness. Also, it seems that security checks are duplicated in the the toolkit and urlimagesource.
18-02-2009