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

Java 8 has slow GUI update after a second

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0"
      Java(TM) SE Runtime Environment (build 1.8.0-b132)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux filesrv 3.11.10-7-desktop #1 SMP PREEMPT Mon Feb 3 09:41:24 UTC 2014 (750023e) x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Since I installed JDK 8 for Linux (64 bit version), some Java applications have a very slow UI update. It is as if the GUI thread falls asleep after a second, and will only refresh the window each half a second or something like that, instead of continuously. I checked this with JDK 8 64 bit and JDK 32 bit and there was no difference. Also using '-client' parameter to the java executable made no difference.

      I added a simple reproduction program. Ofcouse this program has no real value except to demonstrate the problem, but other programs are not responsive either (for example, when selecting a rectangle in a window, the rectangle does not follow the mouse immediately, which is very annoying).


      REGRESSION. Last worked in version 7u51

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.7.0_51"
      Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I made a small test program to reproduce this. It shows 8 buttons. They change colors one after another. First button 1 becomes black, then button 1 reverts to red and button 2 becomes black, then button 2 reverts to red and button 3 becomes black, etcetera. The result is a continuously moving black block from left to right (100 ms between each color change).

      Save the attached source as SlowGuiUpdate.java and compile the source. Try to run this with Java 7 and Java 8 and see the difference (at least on Linux).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Each button color change should be visible as described. You see the black block moving from left to right, and then again from left to right, infinitely. This works perfectly in Java 7.
      ACTUAL -
      The block moves for about a second, and then not every update is visible anymore. Updating becomes slow, so only each half a second, a button becomes black. There is no continuously moving black button anymore. Semi-random buttons turn black.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error messages

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Color;
      import java.awt.Dimension;
      import java.awt.GridLayout;

      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.SwingUtilities;

      public class SlowGuiUpdate {
      public static void main(String[] args) throws Exception {
      JFrame f = new JFrame();
      int num=8;
      GridLayout gl = new GridLayout(1,num);
      f.getContentPane().setLayout(gl);
      final JButton[] buttons = new JButton[num];
      for (int i=0; i<num; i++) {
      buttons[i] = new JButton(Integer.toString(i+1));
      f.getContentPane().add(buttons[i]);
      }
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.setPreferredSize(new Dimension(400,50));
      f.pack();
      f.setVisible(true);

      while (true) {
      for (int i=0; i<num; i++) {
      setColor(buttons, i, Color.BLACK);
      try {
      Thread.sleep(100);
      } catch (InterruptedException e) {
      }
      setColor(buttons, i, Color.RED);
      }
      }
      }

      public static void setColor(final JButton[] buttons, final int i, final Color c) {
      SwingUtilities.invokeLater(new Runnable() {
      public void run() {
      buttons[i].setBackground(c);
      }
      });
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      As far as I know, there is no workaround.

      I find it difficult to choose the severity below. At this point, I can't use Java 8 for GUI stuff, so there is no point in converting my sources to Java 8. I can still use Java 7.


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              azvegint Alexander Zvegintsev
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: