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

Modal Dialog/Stage shows behind "older" window

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: openjfx11
    • Fix Version/s: None
    • Component/s: javafx

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Tested on Ubuntu 18.08 and Ubuntu 18.10.

      A DESCRIPTION OF THE PROBLEM :
      Window order is not always correct. On the source code test case it sometimes shows correctly and sometimes the dialog that should be on the top shows behind a window that was previosly opened.

      It's seems to be an issue with the event order or threading.

      Ou our application the problem always happens becase we run some more core on the constructor so it may affect the order of events. Since this simple example with no extra code sometimes shows the problem, we suspect it's a javafx bug.

      Also reported here https://github.com/javafxports/openjdk-jfx/issues/377.

      I have put some non-blocking breakpoints on the suspected code using Intellij Idea with downloaded sources and successflly catched the out-of-order events:

      WHEN THE PROBLEM IS SHOWN:
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:140)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:122)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:126)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:140)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:122)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)


      WHEN THE WINDOW ORDER IS AS EXPECTED:

      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:140)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:140)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:122)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:126)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:122)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:100)
      Breakpoint reached at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:69)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run source code sample a few times, the results will vary. May depend on machine power since it seems to be related to threading/event control.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The dialog with the title "Last Dialog" should ALWAYS show on top.
      ACTUAL -
      The dialog with the title "Last Dialog" is sometimes behind the Stage named "First Window".

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ButtonType;
      import javafx.scene.control.Dialog;
      import javafx.scene.control.Label;
      import javafx.stage.Modality;
      import javafx.stage.Stage;
      import javafx.stage.Window;

      public class HelloFx extends Application {
          @Override
          public void start(Stage primaryStage) {
              
              Scene scene = new Scene(new Label("Primary Stage"), 640, 480);
              primaryStage.setScene(scene);
              primaryStage.show();
              
              new TestStage(primaryStage, "First Window").show();

              TestStage secondStage = new TestStage(primaryStage, "Second Window");
              secondStage.show();

              openLastWindow(secondStage);
          }
          
          void openLastWindow(Window owner) {
              Dialog dialog = new Dialog();
              dialog.initOwner(owner);
              dialog.setContentText("Hello world!");
              dialog.setTitle("Last Dialog");
              dialog.initModality(Modality.WINDOW_MODAL);
              dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);

              dialog.showAndWait();
          }
      }

      class TestStage extends Stage {
          public TestStage(Window owner, String title) {
              initOwner(owner);
              setTitle(title);
              
              this.setScene(new Scene(new Label("Hello World!"), 400, 400));
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Did not find one.

      FREQUENCY : often


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kcr Kevin Rushforth
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: