My class extends a JavaFX Stage. In a development environment it never fails to load and process, but my users regularly report that sometimes it doesn't properly show which looks like this on Windows 10.
The class itself is a fairly standard affair, I trigger it with Platform.runLater() and the thread processes as expected. Every log output is written out and it is possible to interact with the screen as programmed, or close it, which does not trigger any error or exception.
The stage constructor is pretty basic:
log.debug("Constructing the screen.");
setTitle("Screen");
setAlwaysOnTop(true);
initStyle(StageStyle.UNDECORATED);
try {
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("....fxml"));
Pane panel = fxmlLoader.load();
controller = fxmlLoader.getController();
controller.postInit(currentIdle); // some elements processed
Scene scene = new Scene(panel);
setScene(scene);
scene.setOnKeyPressed(controller::handleKeyEvent);
setOnHiding((WindowEvent e) -> processor::leaveScreen);
log.debug("Showing the screen.");
show();
log.debug("Screen shown.");
requestFocus();
log.debug("Finished constructing the screen.");
} catch (IOException e) {
// ...doesn't go here
}
From the logs everything seems to work as intended, including the controls, keyboard shortcuts and the leaveScreen() hook, and there are no exceptions thrown, except that the user sometimes cannot see the content and controls on the screen.
What am I looking at? Is this a problem with my code, or a JavaFX bug? A problem with graphics on the user laptop? Can you think of a way to prevent or at least detect this state and force a refresh somehow?
Alternatively, under what circumstances is it possible that a JavaFX stage passes its show() method without an error, but does not actually show its contents?
Environments affected: All combinations of latest JDK 14 GA, Corretto 11, (custom jlink-created image) and JavaFX 11.0.2 or 14.0.1 - it does not make a difference. It also happens regardless of whether the application is installed with a jlinked JRE using jpackage or Advanced Installer.