Javafx 为什么这么简单的动画会消耗大量cpu?

Javafx 为什么这么简单的动画会消耗大量cpu?,javafx,Javafx,这个例子简单,cpu消耗高,是bug还是设计技术失败? 细节:让程序运行,注意CPU消耗正在增加 许多程序员,像我一样,喜欢javafx,当这种方法出现时,post工作人员应该放上setCache(true); 但显然这并不能解决问题 我还认为Platform.runLater,当有很多cpu时,它会进入队列,最终会影响cpu的使用 这个问题是从哪里来的,我想让该地区的同事检查一下您的javafx是否遇到了相同的错误 在Ubuntu中,我打开了终端并称之为“top”,还打开了cpu使用率统计数据

这个例子简单,cpu消耗高,是bug还是设计技术失败? 细节:让程序运行,注意CPU消耗正在增加

许多程序员,像我一样,喜欢javafx,当这种方法出现时,post工作人员应该放上setCache(true); 但显然这并不能解决问题

我还认为Platform.runLater,当有很多cpu时,它会进入队列,最终会影响cpu的使用

这个问题是从哪里来的,我想让该地区的同事检查一下您的javafx是否遇到了相同的错误

在Ubuntu中,我打开了终端并称之为“top”,还打开了cpu使用率统计数据的图形显示,这确实有问题

Ubuntu 14.04.1

PPSRenderer:scenario.effect -createShader:Blend_HARD_LIGHT PPSRenderer:scenario.effect-createShader:LinearConvolveShadow_24

java版本“1.8.0_112”java(TM)SE运行时环境(构建 1.8.0_112-b15)Java热点(TM)64位服务器虚拟机(构建25.112-b15,混合模式)


谢谢

在我的MacBook pro上,cpu使用率徘徊在5-6%左右,有时会跳到10%。您是否尝试使用缓冲区?Java是否可能出于某种原因使用您机器上的软件管道?尝试使用
-Dprism.verbose=true运行以启用详细日志记录。在我的计算机cpu中,大约35-92%的内存使用率似乎也在上升吗?这可能与Mesa>=11和JavaFX(类似)的其他问题有关,尽管这是一个未经证实的猜测。在我的MacBook pro上,cpu使用率徘徊在5-6%左右,有时高达10%。您是否尝试使用缓冲区?Java是否可能出于某种原因在您的机器上使用软件管道?尝试使用
-Dprism.verbose=true运行以启用详细日志记录。在我的计算机cpu中,大约35-92%的内存使用率似乎也在上升吗?这可能与Mesa>=11和JavaFX(like)的其他问题有关,尽管这是一个未经证实的猜测。
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 = 16 Maximum number
of texture units usable in a fragment shader = 16 Graphics Vendor:
X.Org
   Renderer: Gallium 0.4 on AMD ARUBA (DRM 2.43.0, LLVM 3.8.0)
    Version: 3.0 Mesa 11.2.0  vsync: true vpipe: true new alphas ES2ResourceFactory: Prism - createStockShader:
Texture_LinearGradient_PAD.frag new alphas ES2ResourceFactory: Prism -
createStockShader: Solid_TextureRGB.frag 
import javafx.animation.KeyValue;  
import javafx.animation.Timeline;  
import javafx.application.Application;  
import javafx.event.ActionEvent;  
import javafx.event.EventHandler;  
import javafx.scene.CacheHint;  
import javafx.scene.Group;  
import javafx.scene.Scene;  
import javafx.scene.control.Button;  
import javafx.scene.control.Label;  
import javafx.scene.image.Image;  
import javafx.scene.image.ImageView;  
import javafx.scene.layout.StackPane;  
import javafx.stage.Stage;  
import javafx.util.Duration;  


public class AnimatedTeste extends Application {  

    @Override  
    public void start(Stage primaryStage) {  

        ImageView imv = new ImageView("http://icons.iconarchive.com/icons/icons-land/sport/16/Tennis-Ball-icon.png");  
        Label  label = new Label("");  
        label.setGraphic(imv);  


        Timeline tl = new Timeline(new KeyFrame(  
            Duration.millis(500),  

            new KeyValue(label.layoutYProperty(), label.getLayoutY()+15 ),   
            new KeyValue(label.rotateProperty(), 360)  

            ));   


        tl.setAutoReverse(true);  
        tl.setCycleCount(Timeline.INDEFINITE);  
        tl.play();  


        Group root = new Group();  
        root.getChildren().add(label);  

        Scene scene = new Scene(root, 300, 250);  



        primaryStage.setTitle("Hello World!");  
        primaryStage.setScene(scene);  
        primaryStage.show();  
    }  

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

}