JDK-8151170 : WINDOW_MODAL dialog does not popup when restoring iconified owner window, which causes application freeze
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8u60,9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: other
  • CPU: x86
  • Submitted: 2016-03-01
  • Updated: 2020-08-18
  • Resolved: 2016-12-01
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.
JDK 9
9Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 10.0.10586]

A DESCRIPTION OF THE PROBLEM :
When you create a WINDOW_MODAL dialog while it's owner-window is minimized, and you then restore the owner window (click on task bar icon), the owner window pops up, but the dialog remains invisible (probably hidden behind it or still minimized)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a scene containing at least two focusable controls (such as a TextFields for instance)
2. Set it as root for a new stage (Application's primaryStage for instance)
3.a. Add a handler for WindowEvent.ON_CLOSE_REQUEST on that stage
3.b. In this handler, make an Alert, set it's modality to WINDOW_MODAL and its owner as the stage, call its showAndWait() method
4. Launch application, minimize the main window, right-click its taskbar icon, and select "Close Window"
5. Restore the main window by clicking its icon on task bar : its frozen. You can't get focus into the TextField, can't minimize, maximize or close it
6. Press ESCAPE: window unfrozen (the alert has been closed)



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The dialog should pop up in front of the owner window when it's restored, so you could read and close it and get back control over your application
ACTUAL -
The dialog is invisible, and the owner window is frozen: you can't get focus into the TextField, can't minimize, maximize or close it

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package application;
	
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;


public class Main extends Application {
	@Override
	public void start(Stage primaryStage) {
		try {
			BorderPane root = new BorderPane();
			TextField tf1 = new TextField();
			tf1.setPrefColumnCount(10);
			TextField tf2 = new TextField();
			tf2.setPrefColumnCount(10);
			VBox vb = new VBox(4, tf1, tf2);
			vb.setFillWidth(false);
			vb.setAlignment(Pos.CENTER);
			root.setCenter(vb);
			Scene scene = new Scene(root,400,400);
			scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
			primaryStage.setScene(scene);
			
			primaryStage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, (event) -> {
				Alert alert = new Alert(AlertType.INFORMATION, "Close window ?", ButtonType.YES, ButtonType.NO);
				alert.initModality(Modality.WINDOW_MODAL);
				alert.initOwner(primaryStage);
				alert.showAndWait().ifPresent((result) -> {
					if (result == ButtonType.NO)
						event.consume();
				});
			});
			
			primaryStage.show();
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		launch(args);
	}
}

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

CUSTOMER SUBMITTED WORKAROUND :
Press ENTER or ESCAPE on the keyboard when restored owner window is in front : this closes the dialog.


Comments
Changeset: f64f481f18c8 Author: ssadetsky Date: 2016-11-30 17:36 -0800 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/f64f481f18c8 8151170: WINDOW_MODAL dialog does not popup when restoring iconified owner window, which causes application freeze Reviewed-by: kcr
01-12-2016

Given that there is a workaround, and this is not a regression I do not think this warrants a backport to JDK 8u. I am removing the "8-bp" label. Note that the underlying glass bug has always been there, and this specific manifestation of the bug has been present since Dialogs were first introduced in 8u60.
01-12-2016

Fix looks good. +1
01-12-2016

http://cr.openjdk.java.net/~ssadetsky/8151170/webrev.00/
30-11-2016

See JDK-8154851 for additional information from the bug reporter.
22-04-2016

This is a pretty serious bug and warrants consideration for a backport to 8u, if a safe fix can be found.
02-04-2016

not a problem on Mac, Linux, reproduced with Windows 8 & 10 guessing that glass needs to check for a modal child and restore it. Note on linux, only the child appears until after the dialog has been dismissed which is also a bit odd
01-04-2016

I have attached a thread stack dump.
01-04-2016

I can reproduce this on Windows, and yes it looks like the issue is probably in glass.
01-04-2016

Kevin - could you please test this on Windows? on OS X I can't seem to see any issue here. If you can reproduce, I would think it is a glass issue rather than a controls issue.
03-03-2016

This might be a graphics bug or a window-toolkit (glass) bug rather than a controls bug. Please reassign it if that is the case.
03-03-2016