Poor performance of javafx ported app

余生颓废 提交于 2019-12-22 09:49:07

问题


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


回答1:


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...



来源:https://stackoverflow.com/questions/40369300/poor-performance-of-javafx-ported-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!