Hi Mike,
As long as you are doing any of the "heavy lifting" on the FX
application thread it will necessarily starve the rendering, since the
application thread is where animation is run and rendering is triggered.
Applications are encouraged to do computationally expensive tasks or
tasks that are subject to blocking (e.g., network reads) on a different
thread.
You have a couple of choices:
1) Use a Preloader to display the splash screen. Do most of your
initialization in the init method of the app, and then construct the
scene graph and display it in the start method of the app. Further, as
long as you don't create a Scene, you can construct much of your scene
graph in the init method, too (there are also some controls that cannot
be constructed off the App thread due to known issues).
2) Similar to above, but without a Preloader: Create the splash screen
in your start method. Do most of your initialization on a background
thread (which you would also create in the start() method), allowing
start() to return quickly; when the initialization is done, call
Platform.runLater() to construct the scene graph.
Hope this helps.
-- Kevin
Mike Hearn wrote:
I'd like to create my main stage, show some splash widgets, then begin the
slower process of hauling the data and rest of the main UI into memory.
Unfortunately when I do this most of the startup time has the stage being
empty, instead of showing the splash. Introducing some artificial delays
makes it reliably appear, but of course I don't want to slow down startup.
My guess is that the app initialisation work is starving the render thread,
so the pixels for the splash don't hit the screen quickly enough. I tried
using an AnimationTimer to wait for a few pulses, but it didn't work. Ditto
for plain old runLater.
If anyone has ideas, it'd be appreciated.