processing / processing4-javafx

JavaFX library for Processing 4
14 stars 5 forks source link

Calling exit() using FX2D renderer doesn’t stop program. #2

Open rhpenguins opened 5 years ago

rhpenguins commented 5 years ago
## Description

Calling exit() using FX2D renderer doesn’t stop the program.

Expected Behavior

When exit() is called in the program the Java app doesn't properly shut down, and throws an error: Not on FX application thread; currentThread = JavaFX Application Thread. The only way to fully exit the sketch is to stop it from within the IDE.

It seems that this only affects Mac users.

Current Behavior

Steps to Reproduce

void setup() {
  size(100,100,FX2D);
  exit();
}

Your Environment

Possible Causes / Solutions

jeremydouglass commented 5 years ago

I also got this error on macOS Sierra (10.12.6)

ezzabi commented 5 years ago

stop

On Wed, Dec 12, 2018 at 6:00 PM Jeremy Douglass notifications@github.com wrote:

I also got this error on macOS Sierra (10.12.6)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/processing/processing/issues/5722#issuecomment-446776761, or mute the thread https://github.com/notifications/unsubscribe-auth/AIX89RbTFq2GjI1So5TRhXs0EVyzNvlXks5u4YqOgaJpZM4ZQkNG .

berserkingyadis commented 4 years ago

I am using Windows 10 and (when using the FX2D renderer) when exiting the program, a Java Process still remains in the Process Explorer. This does not happen when using the Default renderer (Java2D)

I am using Processing 3.5.3 and G4P 4.2.1

chillibasket commented 2 years ago

I've come across these issues in a JavaFX application I wrote a while back. While I don't have a permanent fix, here are the workarounds I came up with back then. There are two issues; one affecting only Mac OS and the other only Windows:

void setup() { size(400, 300, FX2D); dh = new DisposeHandler(this); thread("backgroundThread"); }

public class DisposeHandler {
DisposeHandler(PApplet pa) { pa.registerMethod("dispose", this); }

public void dispose() { exit(); } }

// Example infinite background thread void backgroundThread() { while (true) { delay(1000); } }



- Both of these fixes can be used together to make the sketch work on both platforms, and I haven't come across any side-effects yet...