processing / processing-video

GStreamer-based video library for Processing
274 stars 130 forks source link

NPE "warnings" when starting the webcam #171

Open hamoid opened 3 years ago

hamoid commented 3 years ago

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?

neilcsmith-net commented 3 years ago

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

hamoid commented 3 years ago

Thank you Neil for taking the time to comment :)

neilcsmith-net commented 3 years ago

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

hamoid commented 3 years ago

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

neilcsmith-net commented 3 years ago

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