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

PixelGrabber.grabPixels runs up to 600 times slower on JDK1.4.1 than on JDK1.3.1

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      b26
    • CPU:
      generic, other, x86, sparc
    • OS:
      linux, solaris, solaris_8, solaris_9, solaris_10
    • Verification:
      Verified

      Description

      Name: rmT116609 Date: 03/20/2003


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

      versus

      java version "1.3.1_03"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_03-b03)
      Java HotSpot(TM) Client VM (build 1.3.1_03-b03, mixed mode)


      FULL OS VERSION :
      SunOS trust 5.8 Generic_108528-18 sun4u sparc SUNW,Sun-Blade-100

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      24-bit color

      A DESCRIPTION OF THE PROBLEM :
      The sample program below takes about 93 seconds to execute the grabPixels() call under JDK 1.4.1 on a Solaris 8, Blade 100. It takes 0.16 seconds
      under JDK 1.3.1. (For systems with 8-bit color, the time is about 0.1 seconds under both JDKs.)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code on a 24-bit color Blade 100, Solaris 8 under JDK1.4.1 and JDK1.3.1. The output to standard out shows the times for the grabPixels call

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      execution time of about 200 milliseconds in all cases
      JDK 1.4.1 output is about 93000 milliseconds
      JDK 1.3.1 output is about 160 millseconds

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import java.awt.image.*;
      import javax.swing.*;

      public class Pixel implements ActionListener {

         private JButton b;
         private JFrame f;

         public Pixel () {
        
      f = new JFrame("Copy Frame");
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.setSize(700,500);
      Container cp = f.getContentPane();
      JPanel p = new JPanel();
      cp.add(p);
      b = new JButton("Copy It");
      b.addActionListener (this);
      p.add(b);
      f.setVisible( true);
         }

         public void actionPerformed (ActionEvent e) {

      if (e.getSource() == b) {
      Dimension size = f.getSize();
      Image im = f.createImage(size.width,size.height);
      Graphics gr = im.getGraphics();
      f.printAll(gr);

      int [] pixels = new int[size.width*size.height];
      PixelGrabber pg = new PixelGrabber (im, 0, 0,
      size.width, size.height, pixels, 0, size.width);
      try {
      long start = System.currentTimeMillis();
      System.out.println("starting");
      pg.grabPixels();
      long end = System.currentTimeMillis();
      System.out.println("end after "+ (end-start) + " ms");
      } catch (InterruptedException ie) {
      System.out.println("grab exception="+ie);
      }
      }
         }

         public static void main (String[] args) {
      new Pixel();
         }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Replace

      Image im = f.createImage(size.width,size.height);

      with

      BufferedImage im = new BufferedImage(size.width,size.height, BufferedImage.TYPE_INT_RGB);
      (Review ID: 182843)
      ======================================================================

      Name: jk109818 Date: 07/23/2003


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

      FULL OPERATING SYSTEM VERSION :
      SunOS brooke 5.9 Generic_112233-01 sun4u sparc SUNW,Ultra-1

      ADDITIONAL OPERATING SYSTEMS :
      Linux gescher 2.4.19-PMC-SMP #3 SMP Mon Sep 9 22:33:11 CEST 2002 i686 unknown

      A DESCRIPTION OF THE PROBLEM :
      PixelGrabber + setenv DISPLAY slower in java 1.4

      PixelGrabber is too slow in version 1.4 when I'm running a program in a remote machine but displaying the windows in my workstation

      REGRESSION. Last worked in version 1.3

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Log in on another machine; setenv DISPLAY to the machine you are
      2. Run the given program (on the machine you've just logged in) with java 1.2/1.3 and 1.4.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      PixelGrabber should be so fast as in version 1.3.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      output, v.1.3.0:
      Starting
      9
      output, v.1.4.1:
      Starting
      27074

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class Foo {


          public static void main(String[] args) throws Exception {
              String s = "DonaudampfschifffahrtsgesellschaftskapitM-^OÀ»n";
              Frame f = new Frame();
              f.setSize(300, 300);
              f.show();

              Thread.sleep(1500);

              Font font = f.getFont();
              FontMetrics fm = f.getFontMetrics(font);
              int h = fm.getMaxAscent() + fm.getMaxDescent() + 2;
              long sum = 0;

              for(int i = 0; i < 10; i++) {
                  int w = fm.stringWidth(s) + 2;
                  PixelGrabber pg = new PixelGrabber(f.createImage(w, h), 0, 0, w, h, new int[w*h], 0, w);

                  long start = System.currentTimeMillis();
                  pg.grabPixels();
                  long end = System.currentTimeMillis();
                  sum += end - start;
              }

              System.out.println(sum);
              System.exit(0);
          }

      }



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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tdv Dmitri Trembovetski (Inactive)
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: