JDK-4873526 : REGRESSION: remove/add panel to applet noticably slower in 1.4.x
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-06-03
  • Updated: 2003-09-03
  • Resolved: 2003-09-03
Related Reports
Duplicate :  
Relates :  
Description

Name: gm110360			Date: 06/03/2003


FULL PRODUCT VERSION :
1.4.1_02 (build 1.4.1_02-b06)

FULL OS VERSION :
known to fail in at least win xp and win 2000

EXTRA RELEVANT SYSTEM CONFIGURATION :
code was working for years, including even 1.3.x, but suddenly fails in 1.4.1 and 1.4.2beta

A DESCRIPTION OF THE PROBLEM :
An applet consists of 2 components: a contents panel and a button.  The contents panel consists of one of several panels of components which are swapped at run-time.  The first time a panel is added, the applet works fine, but subsequent additions of the "cached" panel cause 1.4.1 and 1.4.2beta to go to 100% utilization and take 10 seconds before properly displaying the panel.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Load applet described above (and whose short complete example is reproduced below), then click on button "Swap Contents".

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Each click should swap the contents between 2 panels very quickly.
ACTUAL -
1.3.x releases did all swaps quickly as expected.  Suddenly, in 1.4.1 and 1.4.2beta, the first click is fine, but subsequent clicks are painfully slow, as the CPU utilization of the client goes to 100% each time.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
// Java code to reproduce bug followed by html file to load applet

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

public class TestRemoveAddApplet extends java.applet.Applet {

  Container contentPanel  = new Panel();
  Button    button        = new Button("Swap contents");

  Panel     contents1     = new Panel();
  Panel     contents2     = new Panel();
  
  Label     contentsL1    = new Label("Contents #1");
  Label     contentsL2    = new Label("Contents #2");
  
  Component current       = contents2;
  
  public void init() {
    setLayout(new BorderLayout());
    add(contentPanel,"Center");
    add(button,"South");

    button.addActionListener(new Swap());

    contents1.add(contentsL1);
    contents2.add(contentsL2);

    // initialize contents
    swapContents();
  }

  class Swap implements ActionListener {
    public void actionPerformed(ActionEvent e) {
      swapContents();
    }
  }

  void swapContents() {
    current = (current == contents1 ? contents2 : contents1);

    // remove contents of previous contents panel
    contentPanel.removeAll();

    // display new contents
    contentPanel.add(current);
    
    validate();
  }
}


HTML file follows:

<HTML>
<HEAD>
<TITLE>Test Remove / Add in Applet</TITLE>
</HEAD>

<BODY>

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
  WIDTH = 100% HEIGHT = 100% >

<PARAM NAME = CODE VALUE = "TestRemoveAddApplet" >
<PARAM TYPE = "application/x-java-applet;version=1.1" >

</OBJECT>

</BODY>
</HTML>

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

CUSTOMER SUBMITTED WORKAROUND :
none known.  Please provide if discovered.  This is a show-stopping bug in a production, highly used, mission-critical applet.

Release Regression From : 1.3.1_08
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 186724) 
======================================================================

Comments
EVALUATION I wonder if this is related to 4745222? ###@###.### 2003-06-03 Yes I verified that this is indeed same as 4745222. ###@###.### 2003-09-03 Fixed in Tiger. ###@###.### 2003-09-05
03-06-2003