Buffer related exception with Movies and P3D

edited May 2016 in Library Questions

I have a program that processes frames of webcam video, and I am getting intermittent crashing with the following exception:

java.lang.IndexOutOfBoundsException: Required 691200 remaining bytes in buffer, only had 0 java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58) at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103) at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206) at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172) at javax.media.opengl.Threading.invoke(Threading.java:191) at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:541) at processing.opengl.PJOGL.requestDraw(PJOGL.java:688) at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1651) at processing.core.PApplet.run(PApplet.java:2256) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.LinkedList.checkElementIndex(LinkedList.java:553) at java.util.LinkedList.remove(LinkedList.java:523) at processing.opengl.Texture.bufferUpdate(Texture.java:931) at processing.opengl.PGraphicsOpenGL.getTexture(PGraphicsOpenGL.java:6126) at processing.opengl.PGraphicsOpenGL$TexCache.getTexture(PGraphicsOpenGL.java:6918) at processing.opengl.PGraphicsOpenGL.flushPolys(PGraphicsOpenGL.java:2464) at processing.opengl.PGraphicsOpenGL.flush(PGraphicsOpenGL.java:2415) at processing.opengl.PGraphicsOpenGL.endDraw(PGraphicsOpenGL.java:1712) at processing.core.PApplet.handleDraw(PApplet.java:2406) at processing.opengl.PJOGL$PGLListener.display(PJOGL.java:862) at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:665) at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:649) at javax.media.opengl.awt.GLCanvas$10.run(GLCanvas.java:1289) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1119) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:994) at javax.media.opengl.awt.GLCanvas$11.run(GLCanvas.java:1300) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:302) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:703) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

This only happens with the P3D or P2D engines, not with the default one. The program is a little big so I won't post all the code right now, but the main draw function looks like this:

void draw() {  
  if (!blur_on)
    tint(255, 255); //reset opacity

    if(cam.available()) {
      cam.read();

      if(chromakey_on)
        Chromakey(chromakey_mode);
      if(posterize_on)
        Posterize(posterize_mode, posterize_palette);
      if(experimental_on)
        Experimental();
      if(edge_on)
        Edge();
      if(anaglyph_on)
        Anaglyph();

       //display video behind camera image
       //this needs to happen after effects are applied or it breaks chromakey mode 2

      image(mov_left, 0, 0, width, height);
      tint(255, video_xfade_factor);
      image(mov_right,0,0,width,height);
      tint(255, video_transparency);

      if(!anaglyph_on && !edge_on)
        image(cam, 0, 0, width, height);
    }
}

//read video frames
void movieEvent(Movie m) {
  if(m.available()) {
    m.read();
    frame = m.get(); //copy to PImage buffer
  }
}

Am I just trying to display too much at once? Can this be done? I'm on Mac OS, so if I can get to an appropriately configured Windows computer I will see if it's platform specific

Sign In or Register to comment.