processing-video icon indicating copy to clipboard operation
processing-video copied to clipboard

NPE "warnings" when starting the webcam

Open hamoid opened this issue 4 years ago • 5 comments

Hi,

In my current program (3 midi controllers, one webcam, one video file, loading meshes, a web server, OSC) I see a bunch of NPEs in the console printed by Capture.

The program works fine, but the console is quite full and red because of jogamp warnings, jetty being noisy and now the following shown 8 times:

Processing video library using GStreamer 1.16.2
java.lang.NullPointerException
	at processing.opengl.Texture.copyBufferFromSource(Texture.java:827)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at processing.video.Capture$NewSampleListener.newSample(Unknown Source)
	at org.freedesktop.gstreamer.elements.AppSink$2.callback(AppSink.java:232)
	at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:520)
	at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:551)

Since it was shown 8 times I wondered if it was related to 8 frames, so I added if(frameCount > 10) around the webcam .read() and "draw" and those errors are gone. Something to do with slow start up of my program?

hamoid avatar Dec 01 '20 16:12 hamoid

This is probably related to #166 - the code for direct to texture was not correctly updated for GStreamer 1.x.

neilcsmith-net avatar Jan 19 '21 16:01 neilcsmith-net

Thank you Neil for taking the time to comment :)

hamoid avatar Jan 19 '21 16:01 hamoid

@hamoid well, you know where you can find integration with GStreamer 1.x that works correctly :wink:

Looking at your stack trace, the problem is probably at https://github.com/processing/processing/blob/master/core/src/processing/opengl/Texture.java#L827 - usedBuffers can be null there. Needs fixing when 166 is fixed or it will cause a native memory leak.

neilcsmith-net avatar Jan 30 '21 11:01 neilcsmith-net

Thanks @neilcsmith-net , I was just informing for other users and developers. I think we both have found a way to avoid such issues :-)

hamoid avatar Jan 30 '21 11:01 hamoid

@hamoid good to hear! Yes, same, trying to document the key areas where interaction between the video library and GStreamer 1.x / gst1-java-core are failing - do keep a loose eye on issues here (as with other users) in case they're pointers to upstream bugs.

neilcsmith-net avatar Jan 30 '21 11:01 neilcsmith-net