# I crushed the GSVideo problematic frame error!

Nerd warning: This post really belongs on my nerd blog VXLabs.com, but as this blog has a rich tradition of popular processing posts, I’m posting it here.

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  ---------------

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  CathetAR.draw()V+22


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!

### Update on 2011-03-06

Andres Colubri, author of GSVideo, has refined and integrated my patch. The next GSVideo release (0.8 and newer) should have this fix.

### Update on 2011-03-15

Andres has just released GSVideo 0.8, which integrates my fix and many other improvements. Go read his 0.8 release post!

## 5 thoughts on “I crushed the GSVideo problematic frame error!”

1. Pingback: code anti code
2. Pingback: jonobr1
3. Pingback: ira greenberg
4. peripecio says:

Great for the patch!

Good work. Thanks