JDK-8243939 : Window flickers upon launch
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 9,openjfx11,openjfx14
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: os_x
  • CPU: x86
  • Submitted: 2020-04-23
  • Updated: 2020-05-02
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
tbdUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
MacOS X, Catalina
openjdk version "14" 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :
When the stage of an application opens up it first shows its white background before filling it with the content of the root node. This can cause a flicker. On desktop systems this flicker is very short and hardly noticeable but on slower devices, e.g. mobile devices, it becomes very noticeable. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Any application shows this behaviour.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The stage should immediately show the root node of the scenegraph.
ACTUAL -
The window is initially empty / white.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class BugDemo extends Application {

   public void start(Stage stage) {
       VBox root = new VBox();
       root.setStyle("-fx-background-color: orange;");
       Scene scene = new Scene(root, 1000, 800);
       stage.setScene(scene);
       stage.show();
   }

   public static void main(String[] args) {
       launch(args);
   }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Theoretically the application could not use CSS but API to fill the background with a color that more resembles the background color of the root node. This way the flicker is less strong.

FREQUENCY : always



Comments
I can reproduce this on macOS. This is essentially that same problem that was reported in Emsemble8 in JDK-8170421. The workaround, which is pointed out in the above Description, is what we did to fix JDK-8170421. We changed Ensemble8 to set a Scene fill color to a value that most closely matches the color of the scene background. This behavior is a result of the very imperfect fix for JDK-8088179, which calls setBackground with the scene fill color prior to opening the window. This was further refined by the fix to JDK-8171852 to avoid doing this on the Windows platform (except in the case of applets), so this problem does not affect Windows. To fully solve this problem would require changes (at least in glass and maybe prism) for each affected platform to delay showing the window until after the first CSS and layout pass.
02-05-2020