1

This example simple, consume high cpu , is bug or design technology failure ? Detail: let the program run and note that the CPU consumption is increasing...

Many programmers, like me, like javafx, and when that kind of approach pops up, the post staff should put setCache(true); But apparently it is not solving.

I also think that Platform.runLater, when there are many it goes to the queue and ends up harming the use too much of the cpu.

Where does the problem come from, I would like colleagues in the area to check if the javafx of you is experiencing the same error !!?

Here in Ubuntu I opened the teminal and called the "top", and also opened the graphical display of cpu usage statistics, and there really is something wrong.

Ubuntu 14.04.1

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 

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

java version "1.8.0_112" Java(TM) SE Runtime Environment (build 1.8.0_112-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

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

}  

Thanks

Tretonis
  • 27
  • 5
  • On my MacBook pro this hovers around 5-6% cpu usage, sometimes jumping up to ~10%. – James_D Nov 21 '16 at 20:16
  • Did you try to use buffer? – Davuz Nov 21 '16 at 20:18
  • Is it possible Java uses the software pipeline on your machine for some reason? Try running with `-Dprism.verbose=true` to enable verbose logging. – Itai Nov 21 '16 at 20:26
  • in my computer cpu around 35-92% – Tretonis Nov 21 '16 at 20:46
  • Does memory usage seem to climb as well? It may be related to other problems with Mesa>=11 and JavaFX (like [this](http://stackoverflow.com/questions/40228866/optimizing-memory-leakage-in-javafx/40239829#40239829) ), although this is an unsubstantiated guess. – Itai Nov 21 '16 at 21:11
  • Following a bug report on Mesa, could you try running this after running `export LIBGL_DRI3_DISABLE=1` in the same terminal, and see if it makes a difference? – Itai Nov 23 '16 at 20:24
  • I tested and no difference. – Tretonis Nov 24 '16 at 23:59

0 Answers0