随机延迟显示JavaFX场景

时间:2017-07-25 12:14:00

标签: javafx show scene stage borderpane

我已经创建了一个JavaFX应用程序(在Ubuntu上运行,Java(TM)SE运行时环境(版本1.8.0_131-b11))并且已经创建了一个简单的测试应用程序:

  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();
    }
  }

问题在于,有时,在显示舞台后,场景未加载。有时显示按钮需要一秒钟,有时超过20秒。当场景尚未显示并单击场景时,按钮立即显示。同样,有时按钮会在启动时正确显示。正如随机提到的那样。要重现此行为,必须多次重新启动应用程序。我在哪里弄错了?是bug吗?它可能在其他环境中无法重现(Windows,其他JAVA版本......)?

非常感谢!

更新 输出-Dprism.verbose=true选项:

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

0 个答案:

没有答案