Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4712154

Java 1.4 locks the applet GUI while loading images

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 6
    • 1.4.0
    • deploy
    • x86
    • windows_98

      Name: nt126004 Date: 07/09/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


      FULL OPERATING SYSTEM VERSION :

      Windows 98 [Version 4.10.2222]

      A DESCRIPTION OF THE PROBLEM :
      1. Java 1.4 hangs the applet (or the applet GUI) when the
      applet attempts to load images. The attached sample applet
      demonstrates this.

      --> The problem is a new 1.4 behavior that I think is just wrong wrong
      wrong. In 1.4 in the ocx, getImage() DOES NOT RETURN until the entire image
      has been fully loaded. This is critical to understand. getImage() is an
      asynchronous function call. However, the 1.4 plugin really does turn it
      into a synchronous function call (waits until the image data is FULLY
      downloaded -- not good). That is just wrong and must change. Testers will
      never see this problem unless testing on a slow modem line, which I know is
      a huge issue with any applet developer.

      Sorry, in my 'appletlock' I am experimenting with a workaround, but try this
      on for size:

      http://www.duckware.com/bugs/nodisplay.html

      =========================================
      import java.awt.*;
      import java.applet.*;

      public class nodisplay extends Applet {
          private Image m_image;
          public void paint( Graphics g ) {
              g.setColor( Color.red );
              g.fillRect( 0, 0, 1000, 1000 );
              if (m_image==null) {
                  System.out.println( "+getimage" );
                  m_image = getImage( getDocumentBase(), "test.gif" );
                  System.out.println( "-getimage" );
                  }
              System.out.println( "+draw" );
              g.drawImage( m_image, 0, 0, this );
              System.out.println( "-draw" );
              }
          }
      =========================================

      Sorry, but you will only see what is happening if you are on a modem line...

      2d is not an issue since this is the Java 1.1 API for applets, but your new
      plugin must support! Also, if you are curious, check out my duckware
      applets. I do know a thing or two about high performance graphics (but of
      course, use a Java 1.1 VM to view the applets as Java 1.4 busts all of my
      applets!!! -- for which I am attempting to find workarounds).

      - Jerry

      2. It appears that the 1.4 plug-in attempts to
      display what images are being loaded within a 'status
      window' in the applet window. This is a huge problem and a
      major step backwards for ALL applets. What about applets
      that present a GUI and load images in the background? What
      about applets that display images as they are loaded (like
      an object movie)? What about slideshow applets? Do not
      hijack the applet GUI away from programmers -- we know what
      we are doing. Not all images loaded by an applet are
      needed at startup, which it appears your change to the
      applet GUI incorrectly assumes.

      3. Related to (2), the 'status line' displays a status of
      everything that is loading (classes/images/etc). The
      status line is incorrectly 'global' and should be local to
      the applet. Consider a web page that contains two (or
      more) applets. Applet 1 can/does dispaly a status line for
      an image that is being loaded in Applet 2.

      REGRESSION. Last worked in version 1.3

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Put attached applet onto a web page
      2. Place a large image alongside the applet (eg: test.jpg)
      3. Run applet, notice the applet GUI is active
      4. In the applet TextField, type "test.jpg" (or any other
      image name on the server) and press enter
      5. Notice the applet GUI locks up until the image is 100%
      loaded

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected: The GUI must not lock up. The applet should
      continue to run while images load.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.applet.*;

      public class appletlock extends Applet implements Runnable {
          private TextField iEdit = new TextField();
          private String m_name;
          private Image m_image;

          //----------------------------------------------------------------------
          public void init() {
              iEdit.setBackground(Color.white);
              setLayout( new BorderLayout() );
              add( "South", iEdit );
              new Thread(this).start();
              }
          //----------------------------------------------------------------------
          public boolean action( Event evt, Object o ) {
              if (evt.target==iEdit) {
                  m_name = iEdit.getText();
                  iEdit.setText("");
                  repaint();
                  }
              return true;
              }
          //----------------------------------------------------------------------
          public void run() {
              for (int loop=0; ;++loop) {
                  int v = 128+(loop%16)*8;
                  setBackground( new Color(v,v,v) );
                  repaint();
                  try { Thread.sleep(100); } catch (Exception e) {}
                  }
              }
          //----------------------------------------------------------------------
          public void paint( Graphics g ) {
              if (m_name!=null) {
                  m_image = getImage(getDocumentBase(),m_name);
                  m_name = null;
                  }
              if (m_image!=null) {
                  g.drawImage( m_image, 0, 0, this );
                  }
              }
          }
      }

      ---------- END SOURCE ----------
      (Review ID: 148118)
      ======================================================================

            mafishersunw Margarita Fisher (Inactive)
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: