siemaeniu500 siemaeniu500 - 2 months ago 23
Android Question

Poor performance of javafx ported app

I just ported using gradlew into android a sample netbeans javafx project called "PuzzlePieces". The app has got soo poor performance, what can cause that?

My device: LG E975, 4.4 kitkat


This question contains some possible reasons why performance on an Android device could be poor in terms of what one could expect based on how the app runs on desktop.

Anyway, there is a quick win in "PuzzlePieces", and it is related to the CSS point mentioned in that question.

The Desk class adds this inline styling:

Desk(int numOfColumns, int numOfRows) {
        setStyle("-fx-background-color: #cccccc; " +
                "-fx-border-color: #464646; " +
                "-fx-effect: innershadow( two-pass-box , rgba(0,0,0,0.8) , 15, 0.0 , 0 , 4 );");

If you just remove the effect:

Desk(int numOfColumns, int numOfRows) {
        setStyle("-fx-background-color: #cccccc; " +
                "-fx-border-color: #464646; ");

you should notice a huge increment in performance.

As a rule of thumb, when porting desktop applications to mobile devices, avoid excessive css styling, and particularly, avoid at all cost css effects.

I haven't tried cache with the pieces, but probably this will help as well.

And it's worth mentioning as well, CPU will matter...