GSVideo is a brilliant library that you can use in processing to capture live video, on Windows, Linux and OSX, and it’s a huge improvement over the built-in capturing support. Unfortunately, a number of us (including some of the 123 students we got to build augmented reality music instruments this September) have been running into a problematic frame error crash that meant captures didn’t last for very long before unceremoniously crashing the application. Error info and stack trace look something like the following (edited for brevity):
# A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c342eee, pid=1564, tid=2052 # # JRE version: 6.0_20-b02 # Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode windows-x86 ) # Problematic frame: # C [msvcr71.dll+0x2eee] # --------------- T H R E A D --------------- Current thread (0x18db7000): JavaThread "Animation Thread" [_thread_in_native, id=2052, stack(0x1bfd0000,0x1c020000)] Stack: [0x1bfd0000,0x1c020000], sp=0x1c01f8a0, free space=13e1c01f384k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [msvcr71.dll+0x2eee] C [java.dll+0x728d] J java.nio.Bits.copyToByteArray(JLjava/lang/Object;JJ)V j java.nio.DirectIntBufferU.get([III)Ljava/nio/IntBuffer;+126 j java.nio.IntBuffer.get([I)Ljava/nio/IntBuffer;+5 j codeanticode.gsvideo.GSCapture.read()V+24 j CathetAR.draw()V+22
Read more about it on this forum thread.
In any case, today I spent some hours I don’t really have and finally managed to crush it. Turns out, and some of you will probably not be surprised, that it was a threading problem. The capture event handler invokeEvent() and the read() call were being interleaved, and the buffer they were using is also not thread-safe. Doh. Some synchronization here and there, and an extra capture buffer, now I can’t get it to crash anymore.
Get the patch here, and a patched GSVideo.jar here. Both of these are for the GSVideo 20110203 test version. If you can’t patch and build it yourself, just copy my GSVideo.jar over the GSVideo.jar in your unpacked GSVideo 20110203 plugin directory (sub-directory library). Update: See below, GSVideo 0.8 has been released and now contains my patch. Rather get the 0.8 download!
Leave me a comment if this helps!
Andres Colubri, author of GSVideo, has refined and integrated my patch. The next GSVideo release (0.8 and newer) should have this fix.
Andres has just released GSVideo 0.8, which integrates my fix and many other improvements. Go read his 0.8 release post!