This content has been marked as final. Show 4 replies
I don't know where your flickering comes from and actually I think that JavaFX should be able to handle such a seemingly trivial case without problems but if you don't find any other more straight forward solution it might be worth using a Canvas instead of an ImageView. Some time ago I have seen here a quite impressive demo on how to integrate the VLC video player into JavaFX this way. The trick was to push the raw pixel data from a memory source into a canvas. This could be done in FullHD at a high frame rate without any flickering. I tried it myself on my laptop and it worked.
Thanks, I'm going to experiment with Canvas a little to see if I can get any better results.
I'll clarify my post a little to make sure it's totally clear what my problem is.
I have a scene that is filled with dynamic content, and usually has 10-15 nodes in it. This scene is rendering at 1920x1080. I have an animation timer that runs at 60hz, and calls into my code on every pulse to update any nodes that have changes to apply to the scene. Some of the nodes swap in new images every 10-15 seconds using the mechanism described above, while other nodes update their position on every pulse to animate around the screen. I track the time between calls to handle() in my animation timer, and normally the pulses are 16.667ms apart very consistently. However, one or two pulses after I see a new image applied the scene, I see the time between pulses jump to 33.333ms ( like we just skipped a pulse ) and even up to close to 100 ms ( several pulses skipped ). Then after a couple of these laggy pulses, the animation timer returns to normal. When this long of a pause occurs between pulses, the animating content on the screen visibly halts, then jumps into position when the next pulse comes through. I also track how long my internal handle() work takes to make sure I'm not introducing the lag and I almost always return in less than 1ms.
I hadn't considered the use of Canvas though. Assuming I can get that drawing operation completed within my handle window, that might resolve the issues I'm seeing.