问题
I have created a JavaFX application (running on Ubuntu, Java(TM) SE Runtime Environment (build 1.8.0_131-b11)) and have made a simple test application:
public class DelayedSceneApplication extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Test");
primaryStage.setResizable(false);
// Root.
BorderPane root = new BorderPane();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
// Buttons box.
HBox buttonBox = new HBox();
buttonBox.setPadding(new Insets(10));
buttonBox.getChildren().addAll(new Button("Test"));
root.setBottom(buttonBox);
primaryStage.show();
}
}
The problem is that sometimes, after the stage has been shown, the scene is not loaded. Sometimes it takes one second to show the button, sometimes more then 20 seconds. When the scene has not been shown yet and clicking on the scene, the button shows immediately. Again, sometimes the button shows correctly at start up. This happens, as mentioned randomly. To reproduce this behavior one has to restart the application multiple times. Where did I make a mistake? Is it bug? Is it maybe not reproducible in an other environment (Windows, other JAVA Version, ...)?
Thank you very much!
Update:
The output with -Dprism.verbose=true
option:
Prism pipeline init order: es2 sw
Using java-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline name = com.sun.prism.es2.ES2Pipeline
Loading ES2 native library ... prism_es2
succeeded.
GLFactory using com.sun.prism.es2.X11GLFactory
(X) Got class = class com.sun.prism.es2.ES2Pipeline
Initialized prism pipeline: com.sun.prism.es2.ES2Pipeline
Maximum supported texture size: 16384
Maximum texture size clamped to 4096
Non power of two texture support = true
Maximum number of vertex attributes = 16
Maximum number of uniform vertex components = 16384
Maximum number of uniform fragment components = 16384
Maximum number of varying components = 128
Maximum number of texture units usable in a vertex shader = 32
Maximum number of texture units usable in a fragment shader = 32
Graphics Vendor: Intel Open Source Technology Center
Renderer: Mesa DRI Intel(R) Kabylake GT2
Version: 3.0 Mesa 17.0.3
vsync: true vpipe: true
ES2ResourceFactory: Prism - createStockShader: FillPgram_Color.frag
new alphas
ES2ResourceFactory: Prism - createStockShader: Texture_Color.frag
ES2ResourceFactory: Prism - createStockShader: Texture_LinearGradient_PAD.frag
ES2ResourceFactory: Prism - createStockShader: Solid_TextureRGB.frag
ES2ResourceFactory: Prism - createStockShader: Solid_TextureFirstPassLCD.frag
ES2ResourceFactory: Prism - createStockShader: Solid_TextureSecondPassLCD.frag
来源:https://stackoverflow.com/questions/45302969/showing-of-javafx-scene-randomly-delayed