Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

2.x PGraphics thread crash

$
0
0
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?

  1. import java.util.concurrent.ExecutorService;
  2. import java.util.concurrent.Executors;
  3. PGraphics buffer;
  4. boolean runthread = false;
  5. ExecutorService executor;
  6. void setup() {
  7.   size(width, height, P3D);
  8.   buffer = createGraphics(width, height, P3D);
  9.   executor = Executors.newFixedThreadPool(1);
  10. }
  11. void draw() {
  12.   //do stuff
  13.   stroke(random(0,255),random(0,255),random(0,255));
  14.   line(random(0,width),random(0,height),random(0,width),random(0,height));
  15.   if (!runthread) {
  16.     runthread = true;
  17.     executor.submit(new RunLoadNodes());
  18.   }
  19. }
  20. void loadbuffer() {
  21.   println("ya");
  22.   buffer.beginDraw();
  23.   //do stuff
  24.   buffer.endDraw();
  25. }
  26. public class RunLoadNodes implements Runnable {
  27.   public RunLoadNodes() {
  28.   }
  29.   public void run() {
  30.       loadbuffer();
  31.   }
  32. }
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

Viewing all articles
Browse latest Browse all 1768

Trending Articles