The single core nature of JavaFX and complex UI construction

Lubomir Nerad lubomir.nerad at
Thu Nov 22 06:17:15 PST 2012

Hi Randahl,

On 11/22/2012 12:02 AM, Randahl Fink Isaksen wrote:
> For some weeks now, I have been struggling with poor UI construction performance in our application. JavaFX renders like a breeze, but the time it takes to construct complex Node trees is unacceptable to end users.
> Our app presents a landscape of data, which the user can navigate freely. A large number of entities are presented in this landscape each in their own little editing panel, complete with buttons, labels and text fields. This works great for small data sets of up to 10 entities. The problem is, that the raw construction of each panel takes around 80 milliseconds – even on my crazily fast 16 core MacPro – because, it seems all UI construction is carried out on a single core. The end result is, constructing a UI containing 50 editing panels takes 50 x 80 milliseconds = 4 seconds. That is not too bad given the complexity of the UI – the real problem is, the UI freezes completely during those 4 seconds, so I am not able to provide animated feedback like, say, a progress bar giving telling the user how long the UI construction will take.
> Now, I have indeed tried a divide and conquer approach where I used 4 separate threads to create the editing panels in parallel, but apparantly that is a no-go, because each UI has complex bindings and listeners which are triggered from my editing panel constructors, and then I end up with deep down JavaFX internal exceptions saying something along the lines of "You have to use the JavaFX thread", which of course is no surprise, recalling the JavaFX single threaded nature.

JavaFX is supposed to support constructing isolated subtrees of the 
scenegraph on separate threads, but then if you need to add them to the 
main tree (connected to the Scene), you'll need to do that final step on 
the main thread. So if you get exceptions while constructing subtrees, 
you should report them in Jira.

> I would be very interested in hearing from other application developers implementing complex UI, if they would be so kind to share their experiences. Or from JavaFX API developers who could share some insights on how to speed up complex UI construction.
> Thanks
> Randahl


More information about the openjfx-dev mailing list