micycle1 / ProcessingFX

A basic project showing how a Processing sketch and an FXML JavaFX stage may be integrated.
11 stars 5 forks source link

Multithreading for PApplet no longer working. #4

Closed martin-y-lu closed 4 years ago

martin-y-lu commented 4 years ago
Screenshot 2020-03-09 at 1 31 34 PM

The multithreading that allows the application and PApplet to run concurrently no longer works. JavaFX is complaining that the application can only be run on the main thread.

java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = main at com.sun.glass.ui.Application.checkEventThread(Application.java:443) at com.sun.glass.ui.Window.getScreen(Window.java:403) at com.sun.javafx.tk.quantum.WindowStage.setBounds(WindowStage.java:289) at javafx.stage.Window$TKBoundsConfigurator.apply(Window.java:1292) at javafx.stage.Window.applyBounds(Window.java:1182) at javafx.stage.Window.centerOnScreen(Window.java:283) at processing.javafx.PSurfaceFX.placeWindow(PSurfaceFX.java:564) at processing.core.PApplet.runSketch(PApplet.java:10849) at processing.core.PApplet.main(PApplet.java:10562) at processing.core.PApplet.main(PApplet.java:10534) at com.micycle.main.Main.main(Main.java:9)

I think a result of this is variables related to the PApplet no longer gets initialissed: java.lang.NullPointerException at com.micycle.javafx.Controller.lambda$initialize$1(Controller.java:48) at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361) at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81) at .... at com.sun.glass.ui.View.notifyMouse(View.java:937)

micycle1 commented 4 years ago

Hmm. Not sure since it works for me and others.

martin-y-lu commented 4 years ago

Nevermind: I found a fix Apparently there is a tread check property in the version of JavaFX I found, For me, the thread check could be disabled by using System.setProperty("glass.disableThreadChecks", "true"); before the multithread event.