JDK-8193502 : [Linux] Dialog height switches between correct and too small when showing and hiding a Dialog repeatedly
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8u60,9,10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2017-12-13
  • Updated: 2019-10-24
  • Resolved: 2019-05-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx13Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux  3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Linux  3.13.0-46-generic #79-Ubuntu SMP Tue Mar 10 20:06:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux



A DESCRIPTION OF THE PROBLEM :
When the same instance of a dialog is repeatedly shown and hidden, its height will switch between being as expected on the first, third, fifth etc. time it is shown, and being much too small the second, fourth, ... time it is shown. 

I could always reproduce the bug on Linux instances.

I could NOT reproduce the bug on Microsoft Windows [Version 6.1.7601] and Java(TM) SE Runtime Environment (build 1.8.0_152-b16).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a dialog with a certain size.
2. Show the dialog.
3. Hide the dialog.
4. Show the same dialog again.
5. Repeat steps 3 and 4. 

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Every time the dialog is shown again after being hidden, it should have the same size/height as before.
ACTUAL -
The dialog size will be fine when first shown. The second time it is shown, its height will be much too small. For the following times it is shown, the dialog's height will consistently switch between being correct (third time, fifth time, ...) and being the same much too small size (fourth time, ...). 

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class TestDialogSizingWhenHiddenAndShownAgain extends Application {

    public static void main(final String[] args) {
        launch(args);
    }

    @Override
    public void start(final Stage stage) {

        final Dialog<Void> testDialog = getTestDialog();

        final Button dialogButton = new Button("Open Dialog");
        dialogButton.setOnAction(evt -> testDialog.show());

        final Scene scene = new Scene(dialogButton, 300, 200);

        stage.setScene(scene);
        stage.show();
    }

    private static Dialog<Void> getTestDialog() {
        final Label dialogContent = new Label();
        dialogContent.setText("Dialog content");
        dialogContent.setPrefSize(300, 300);

        final Dialog<Void> testDialog = new Dialog<>();

        testDialog.getDialogPane().setContent(dialogContent);
        testDialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);

        // enableWorkaround(testDialog);

        return testDialog;
    }

    private static void enableWorkaround(final Dialog<?> dialog) {
        final String PREVIOUS_WIDTH = "PREVIOUS_WIDTH";
        final String PREVIOUS_HEIGHT = "PREVIOUS_HEIGHT";

        dialog.setOnShowing(evt -> {
            dialog.getDialogPane().getProperties().put(PREVIOUS_WIDTH, dialog.getWidth());
            dialog.getDialogPane().getProperties().put(PREVIOUS_HEIGHT, dialog.getHeight());
        });
        dialog.setOnShown(evt -> {
            final double previousWidth = (double) dialog.getDialogPane().getProperties().get(PREVIOUS_WIDTH);
            final double previousHeight = (double) dialog.getDialogPane().getProperties().get(PREVIOUS_HEIGHT);
            if (previousWidth > 0 && previousHeight > 0) {
                dialog.setWidth(previousWidth);
                dialog.setHeight(previousHeight);
            }
        });
    }

}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
On dialog.setOnShowing, remember the dialog's current width and height. On dialog.setOnShown, use dialog.setWidth and dialog.setHeight with the remembered sizes. 


Comments
Changeset: f1d0e1fd236b Author: kcr Date: 2019-05-08 10:54 -0700 URL: http://hg.openjdk.java.net/openjfx/jfx-dev/rt/rev/f1d0e1fd236b 8193502: [Linux] Dialog height switches between correct and too small when showing and hiding a Dialog repeatedly Reviewed-by: kcr, pbansal Contributed-by: thiago.sayao@clamed.com.br
08-05-2019

GItHub PR for review: https://github.com/javafxports/openjdk-jfx/pull/456
26-04-2019

Issue is reproducible in Linux only and its a regression introduced in 8u60. Ubuntu 16.04.2 LTS JDK results --------------------------- 8u52 : Pass 8u60 : Fail <== regression introduced here 8u162 : Fail 9.0.1 : Fail 10-ea+35 : Fail When customer submitted workaround is enabled, issue is not reproducible.
14-12-2017