So I create a buffer to do some work in a separate thread so it does not delay the normal draw. This worked fine in 1.x. Any thoughts on why this now crashes and how to get around it?
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- PGraphics buffer;
- boolean runthread = false;
- ExecutorService executor;
- void setup() {
- size(width, height, P3D);
- buffer = createGraphics(width, height, P3D);
- executor = Executors.newFixedThreadPool(1);
- }
- void draw() {
- //do stuff
- stroke(random(0,255),random(0,255),random(0,255));
- line(random(0,width),random(0,height),random(0,width),random(0,height));
- if (!runthread) {
- runthread = true;
- executor.submit(new RunLoadNodes());
- }
- }
- void loadbuffer() {
- println("ya");
- buffer.beginDraw();
- //do stuff
- buffer.endDraw();
- }
- public class RunLoadNodes implements Runnable {
- public RunLoadNodes() {
- }
- public void run() {
- loadbuffer();
- }
- }
If it helps, here is the crash info:
Application Specific Information:
Java information:
Exception type: Bus Error (0xa) at pc=00000000956d6ea4
Java VM: Java HotSpot(TM) Client VM (20.12-b01-434 mixed mode macosx-x86)
Current thread (0000000002450400): JavaThread "pool-1-thread-1" [_thread_in_native, id=-1314140160, stack(00000000b19bd000,00000000b1abd000)]
Stack: [00000000b19bd000,00000000b1abd000]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j jogamp.opengl.gl4.GL4bcImpl.dispatch_glGetError1(J)I+0
j jogamp.opengl.gl4.GL4bcImpl.glGetError()I+33
j processing.opengl.PGL.getError()I+3
j processing.opengl.PGraphicsOpenGL.report(Ljava/lang/String;)V+13
j processing.opengl.PGraphicsOpenGL.beginDraw()V+3
j sketch_Dec12a.loadbuffer()V+9
j sketch_Dec12a$RunLoadNodes.run()V+4
j java.util.concurrent.Executors$RunnableAdapter.call()Ljava/lang/Object;+4
j java.util.concurrent.FutureTask$Sync.innerRun()V+30
j java.util.concurrent.FutureTask.run()V+4
j java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Ljava/lang/Runnable;)V+59
j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+28
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub