JDK-6751484 : Displaying a JDialog after a second Frame is shown is slow
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2008-09-23
  • Updated: 2011-02-16
  • Resolved: 2009-03-04
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_10-rc2"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc2-b32)
Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)



ADDITIONAL OS VERSION INFORMATION :
SunOS cfsc.pbn.bnl.gov 5.7 Generic_106541-46 sun4u sparc SUNW,Ultra-60
or
Linux acnlin04.pbn.bnl.gov 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
The slowness effect is worse on SUN but is also apparent on LINUX.

A DESCRIPTION OF THE PROBLEM :
Version 1.5 and prior had no problems when displaying a Dialog window after a second JFrame was made visible.  With 1.6 and later this problem has been persistent.  I believe I sent a bug report previously but no solution was ever provided.

The only way to show this problem is to run the sample program I have supplied.  The problem seems to be significantly worse when running on a SUN but it is still apparent from linux.  I have not tried other operating systems.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program I supply and click the "show dialog" button.  Notice the fast response.  Then click the "show frame" button and then click the "show dialog".  Notice how much longer it takes for the dialog to show in this case.  This problem is actually magnified when you have a more complicated user interface involved.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The performance should not be different no matter how many frames are visible.  This is the case in release 1.5 and earlier.
ACTUAL -
The slowness I explained above.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No errors

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

import java.awt.event.*;
import java.awt.*;

/* Simple program to show how displaying a dialog window when a second jframe
   is displayed is very slow on SUN and LINUX */
public class Slow extends JFrame {

    public static void main(String args[]) {

        for (int i=0; i<args.length; i++)
            System.out.println(args[i]);

	// Slow is the "main" window
        Slow s = new Slow();
        s.setVisible(true);
    }

    public Slow() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        JPanel panel = (JPanel) getContentPane();
        panel.setLayout(new GridLayout());
        panel.add(_button1);
        panel.add(_button2);
          
        _button1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if (_frame2 == null)
			_frame2 = new Frame();
                    _frame2.setVisible(true);
                }
            });

        _button2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if (_dialog == null)
			createDialogWindow();
		    _dialog.setVisible(true);
                }
            });
        
        pack();
    }

    public void createDialogWindow() {
	_dialog = new JDialog(this);
 	Container content = _dialog.getContentPane();
 	content.add(new JLabel("Dialog Window"));
	// setModal seems to cause all the problems
 	_dialog.setModal(true);
	_dialog.pack();
    }

    JButton _button1 = new JButton("Show Frame");
    JButton _button2 = new JButton("Show Dialog");
    JDialog _dialog = null;
    JFrame  _frame2 = null;

    class Frame extends JFrame {
        public Frame() {
            enableEvents(AWTEvent.WINDOW_EVENT_MASK);
            
            JPanel panel = (JPanel) getContentPane();
            JLabel l = new JLabel("Click 'Show Dialog' and response to click is slow");
            panel.add(l);

            pack();
        }
    }
}

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

CUSTOMER SUBMITTED WORKAROUND :
I have found no work around.

Release Regression From : 5.0
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION This problem is a duplicate of 6518077: Modal dialogs open slowly with JRE 1.6.0 sun.awt.X11.XToolkit which is fixed in JDK7-b14, and need to be backported to some of JDK6 update releases.
04-03-2009

EVALUATION I was trying to reproduce the issue but the test works OK for me. I ran the test using jdk6u10 b32 on different Linux environments. The result are the same - there is no delay after I click on the 'show dialog' button second time and the dialog appears immediately. Could you provide more information about your environment, which Linux distribution, did you run the test on GNOME or KDE, did you run the test locally or remotely? If possible could you also try to run the test on another Linux machine, is it still reproducible? Is it reproducible using jdk6 b105?
25-09-2008

EVALUATION reassigned to awt
24-09-2008