JDK-4322138 : appletviewer intermittently displays resizable Frame/Dialog when they should not
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2000-03-16
  • Updated: 2004-03-20
  • Resolved: 2003-10-21
Related Reports
Relates :  
Description
As demonstrate in the following applet that should bring up a non-resizable
frame and dialog.  I noticed the following behavior:

- If ran on my own machine the appletviewer would occasionally brought up
  a resizable frame and/or dialog when they all should be non-resizable.
  Aside from been resizable when it shouldn't be, sometimes the frame would
  popped up then disappeared.  Other times, the frame would come up and
  occupied the entire screen and not its programmed size of 100X250.  The
  dialog, sometimes, failed to be displayed as well.

- If run remotely and displayed on my machine, the resizable frame and/or
  dialog would occur more frequent.

- If run the applet in the Netscape browser, the frame is consistently not
  resizable but the dialog is always resizable.  The browser version is
  "Netscape 4.51/U.S., 27-Feb-99; (c) 1995-1998 Netscape Communications Corp.".

- There seems to be a timing related failure here because if the methods
  setResizable(), setVisible(), and setBounds() are shuffled then an
  entirely different behaviors prevail.

- Lastly, my biggest concern is the inconsistent display behavior of the
  appletviewer.

Roger Pham 3/15/2000

--------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class fr extends Applet {

    public void start () {
	Frame f = new Frame("Not Resizable Frame");
	f.setResizable(false);
	f.setVisible(true);
	f.setBounds(100, 100, 250 , 100);

	Dialog d = new Dialog(f, "Not Resizable Dialog");
	d.setResizable(false);
	d.setVisible(true);
	d.setBounds(450, 100, 250, 100);

	setBounds(0, 0, 100 , 100);

	f.add(new Label("Resizable?"));
	d.add(new Label("Resizable?"));
    }
}

<html>
<head> <title>Applet</title> </head>
<body>
	<h1>Applet</h1>

    <applet
      code=fr
      codebase=file:/home/rogerp/java
      width=100
      height=100
    >

    [[Use an applet-enabled browser]]
    </applet>


</body>
</html>

Comments
WORK AROUND Name: dsR10078 Date: 04/30/2000 ###@###.### The behavior is more correct and stable if setVisible(true) is called after setting all other properties (size, resizability etc.). ======================================================================
11-06-2004

EVALUATION Commit to fix in Merlin. eric.hawkes@eng 2000-03-27 Name: dsR10078 Date: 04/30/2000 ###@###.### The test case demonstrates problems different in cause and manifestation: 1.The Frame or Dialog can be resized for some time after it is made visible. But on the next resize attempt it shrinks to the original size and cannot be resized anymore. This problem is documented under BugTraq ID 4313607. 2.The Dialog is sometimes incorrectly sized and on the first resize attempt it shrinks to a very small size (~10x50) and cannot be resized anymore. The problem arises only when we call setBounds() soon after setVisible(true). In this case setVisible() creates widgets for the Dialog of initial size 0x0(1x1) and requests X server to map the shell widget. When the shell is mapped X server will asynchronously send MapNotify. In the test we call setBounds() just after setVisible(true). setBounds() first updates java x,y,width,height fields and then calls the peer to reshape native widgets accordingly. MapNotify can appear in the middle of setBounds() call: between setting java fields and updating native widgets. In responce to MapNotify we update java x,y,width,height fields with the current size of the mapped widget that is different from the new size being set. This inconsistency causes native widgets to be sized incorrectly. Later we use java fields to set fixed min/max size of the shell widget to make it non-resizable. So on any attempt to reshape the frame it will jump to this incorrect fixed size and cannot be resized anymore. ====================================================================== This is another problem caused by the asynchronicity of X event processing. See 4101435 for another example. eric.hawkes@eng 2000-11-13 Despite the fact that this bug does not appear on the AWT JCK-exclude list, there are two JCK tests that are excluded because of this bug. Below is an excerpt of an email from roger.pham@eng If you look at /net/mizu.eng/export4/jck/1.3/fcs/z1/binaries/JCK-runtime-13fcs/lib/jdk13fcs.jtx there are 2 tests that are excluded due to this failure. jdk13fcs.jtx:api/java_awt/interactive/DialogTests.html#DialogTests[DialogTest000 1] 4322138 solaris-sparc jdk13fcs.jtx:api/java_awt/interactive/FrameTests.html#FrameTests[FrameTest0001] 4322138 solaris-sparc Decommitting from Merlin. It is unlikely that this will be fixed. eric.hawkes@eng 2000-11-14 Call updateSizeHints in setBounds in XDecoratedPeer.java Fix the test case, because setVisible must be the last operation on the the Frame and Dialog in start(). Use the new version of metacity window manager in metacity-2.6.2-1.i386.rpm at http://rpmfind.net//linux/RPM/rawhide/1.0/i386/RedHat/RPMS/metacity-2.6.2-1.i386.html which is also required for Bug 4923983. See Suggested Fix for complete fix. ###@###.### 2003-10-17 Name: dmR10075 Date: 10/18/2003 Please note that the fix for XDecoratedPeer is likely to cause regressions - parameters for setBounds depends on the op - they might be in client coordinates system, in window coordinates, or just have dummy values. This is unsafe to always initialize dimensions with this coordinates as if they are always in window coordinates system. Also, there are already two places responsible for setting hints - XBaseWindow.setSizeHints and XWM.setShellResizable/notResizable. If something is wrong with min/max hints it should be fixed there. ###@###.### 2003-10-18 ====================================================================== I recommend using the new version of metacity window manager in metacity-2.6.2-1.i386.rpm at http://rpmfind.net//linux/RPM/rawhide/1.0/i386/RedHat/RPMS/metacity-2.6.2-1.i386.html which is also required for Bug 4923983. It fixes an unrelated layout problem which can be seen when running the test for this bug. However the problem described in this bug is no longer reproducible in the AWT nightly build /net/jano/export/disk03/awt/nightly/archive-TIGER/2003-10-19-Sun.tiger ###@###.### 2003-10-20
20-10-2003

SUGGESTED FIX ------- XDecoratedPeer.java ------- *** /tmp/sccs.EbaGmP Fri Oct 17 19:24:54 2003 --- XDecoratedPeer.java Fri Oct 17 17:24:13 2003 *************** *** 394,400 **** * @see java.awt.peer.ComponentPeer#setBounds */ public void setBounds(int x, int y, int width, int height, int op) { ! // TODO: Rewrite with WindowDimensions reshape(x, y, width, height, op, true, true); validateSurface(); } --- 394,403 ---- * @see java.awt.peer.ComponentPeer#setBounds */ public void setBounds(int x, int y, int width, int height, int op) { ! Rectangle bounds = new Rectangle(x, y, width, height); ! dimensions = new WindowDimensions(bounds, getRealInsets(), false); ! XWM.removeSizeHints(this, XlibWrapper.PMinSize | XlibWrapper.PMaxSize); ! updateSizeHints(); reshape(x, y, width, height, op, true, true); ========================================================================== Fix the test case, because setVisible must be the last operation on the the Frame and Dialog in start(). Here is the fixed test case: import java.awt.*; import java.awt.event.*; import java.applet.*; public class fr extends Applet { public void start () { Frame f = new Frame("Not Resizable Frame"); f.setResizable(false); f.setBounds(100, 100, 250 , 100); f.add(new Label("Resizable?")); f.setVisible(true); Dialog d = new Dialog(f, "Not Resizable Dialog"); d.setResizable(false); d.setBounds(450, 100, 250, 100); d.add(new Label("Resizable?")); d.setVisible(true); setBounds(0, 0, 100 , 100); } } ========================================================================== Use the new version of metacity window manager in metacity-2.6.2-1.i386.rpm at http://rpmfind.net//linux/RPM/rawhide/1.0/i386/RedHat/RPMS/metacity-2.6.2-1.i386.html which is also required for Bug 4923983. ========================================================================== ###@###.### 2003-10-17
17-10-2003