When it comes to performance in JavaFX one of the biggest problems is that if you detach and reattach a big SceneGraph-Part you run:
- CSS-Pass
- Layout-Pass
So in general one should avoid those operations as much as possible but there are situations you can’t get something implemented without doing exactly this kind of thing.
In the current architecture of e(fx)clipse we need to use this reparenting in case of minimizing/maximizing certain areas of your e4-on-JavaFX application which might lead to a very poor user experience if you eg have a MPartStack
with many complex substructures (like eg our code editor).
Today we took a closer look for one of our customers to find out if we – the e(fx)clipse – framework can do anything to fix that problem and after some experiments we managed to come up with a solution who allows us to reparent the content of an MPartStack
in constant time:
In general I’d say that such optimization should not be required and JavaFX CSS and Layout performance HAS to be improved in general and JavaFX-Components have to get smarter in not running CSS-Passes on SG-Parts who are currently not showing.
Hello,
can you please give some details about optimizations you’ve made.
We have very similar issue in our FX application when doing reparent of big nodes graph. We have a set of prepared off-scene nodes and putting one of them on-scene setting it as child of “application root” container. Such operation seems to be very expensive depending on node tree size. At this moment application freezes for one-two seconds.
Thank you in advance.
Well the performance improvements are because we break CSS and Layout calculations if a node is not visible in the SG. To break CSS and Layout reapply at will we have a StackPane subclass http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/LazyStackPane.java?h=2.6.x
This means our strategy only improves your situation if you the SG-Fragment you reattach has many invisible Nodes (eg inside TabPane)
Thank you, this sounds interesting. Sure the same trick can be done in our case too. Will definitely try it out.
Pingback: e(fx)clipse support for Java9 | Tomsondev Blog