benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.35k stars 237 forks source link

P2D and P3D Context Thread Crash #851

Open PeteHaughie opened 1 month ago

PeteHaughie commented 1 month ago

Description

Whilst looking for a simple way to speed up rendering on the main thread I found a consistent crash when using P2D and P3D renderers.

Expected Behavior

Sketch with threaded functions should run happily regardless of context.

Current Behavior

As soon as a context is introduced the sketch crashes with a violation error.

Steps to Reproduce

Working code:

void setup() {
  size(200, 200);
  background(0);
}

void draw() {
  thread("saveImage");
}

void saveImage() {
  saveFrame("output/" + frameCount + ".png");
}

Crashing code:

void setup() {
  size(200, 200, P2D);
  background(0);
}

void draw() {
  thread("saveImage");
}

void saveImage() {
  saveFrame("output/" + frameCount + ".png");
}
void setup() {
  size(200, 200, P3D);
  background(0);
}

void draw() {
  thread("saveImage");
}

void saveImage() {
  saveFrame("output/" + frameCount + ".png");
}

Your Environment