0

after several days of dealing with crashes and tons of debugging I came across a problema with Platform.runLater.

I have an application that executes two thread that update different parts of my interface. One of the threads produces many changes per second on the UI (about 25 changes per second) and after some execution time Platform.runLater simple does nothing...the runnable that is passed by argument just doesn't execute. And the most interesting thing is that even if I kill the JVM, after this behaviour, new starts of the JVM with my aplication show this problem immediately, the only way to recover is to reboot the Machine.

By the way...I'm working is a Raspberry-Pi and Oracle JDK 8

I read on the documentation:

NOTE: applications should avoid flooding JavaFX with too many pending Runnables. Otherwise, the application may become unresponsive. Applications are encouraged to batch up multiple operations into fewer runLater calls. Additionally, long-running operations should be done on a background thread where possible, freeing up the JavaFX Application Thread for GUI operations.

It appears that I should call runLater many times....However I don't see how I can avoid doing this if I really need to update my UI very frequently.

Is there any alternative? Can I execute this inside my main thread thus avoiding the call to Platform.runLater? I tried that however if I "block" the code inside the start method the javaFX application never draws anything, because blocking the application blocks all UI from working.....

Any help will be greatly thanked.....

Thanks in advance!

EDIT:

@James_D suggested a duplicate from thread: Updating UI from different threads in JavaFX

I reimplemented everything with the animation timer... Now I have zero calls to Platform.runLater .. I had implemented this solution before but I wasn't using an animation timer so I was preventing the main application thread from doing it's normal business so it didn't work... however.... and contrary to what I was expecting this did not solve my problem... it appears I'm making something to this JVM that crashes it...after a few minutes my program just hangs...java keeps running but zero logs show...nothing... I kill it, check for processes and have zero java processes but when I restart the application it doesn't even show the initial message saying the JavaFX application started... does anyone know what can cause this behaviour?

Even if I made the worst code in the world, my application should crash but I should be able to kill it and try again. However after the "crash" that is happening my only solution is to reboot the raspberry pi, after the reboot, the exact same application starts "normally" until it crashes again minutes later..repeating the entire behaviour..

Community
  • 1
  • 1
circuit
  • 23
  • 6
  • Have you read about [Task](https://docs.oracle.com/javase/8/javafx/api/javafx/concurrent/Task.html) ? Additionally, you can also visit [JavaFX - Control and Concurrency](http://stackoverflow.com/questions/24983721/javafx-control-and-concurrency) and check both the answers for the difference between Platform.runLater and Task. – ItachiUchiha Jan 09 '16 at 06:29
  • Contrary to what I belived this does not seem to be an issue with the code, so I opened a different thread where I explain the entire problem and all the debug that was made: http://stackoverflow.com/questions/34749347/javafx-raspberry-pi-prism-egl Thank you all for the help! – circuit Jan 12 '16 at 16:52

0 Answers0