arturoc / ofxGStreamer

openFrameworks addon to use gstreamer under osx and windows. This addon has no code and instead uses the addon_config.mk file to add the needed files from the core + the flags needed to compile using gstreamer
56 stars 28 forks source link

GLib-ERROR **: Creating Pipes for GWakeup: Too many open files #15

Closed adielfernandez closed 8 years ago

adielfernandez commented 8 years ago

Hello again,

I've got a weird issue here working with multiple feeds. I am pulling in 14 IP camera feeds and doing CV on them. My app runs just fine as long as I compile/run it from Xcode, but when I try to run the standalone app it crashes when connecting to the 13th camera (but after successfully connecting to the first 12). The app also runs just fine when using videos instead of gstreamer feeds or when I use only 12 cameras in total.

The error I get is: GLib-ERROR **: Creating Pipes for GWakeup: Too many open files

Initial digging shows it's a problem with resources not being cleaned up properly (i.e. sockets/file descriptors not being closed/deleted).

Any idea of what the problem is and why it would run in Xcode but not straight from the App file?

Thanks, Adiel

adielfernandez commented 8 years ago

I've parsed through the Gstreamer debug and found some more info on the errors that are coming back (formatted a bit for easier readability):

WARN                GST_POLL gstpoll.c:602:GstPoll *gst_poll_new(gboolean): 0x7fa6a1912050: can't create socket pair !

(<unknown>:755): GStreamer-CRITICAL **: gst_poll_write_control: assertion 'set != NULL' failed

WARN                  udpsrc gstudpsrc.c:1067:gst_udpsrc_open:<udpsrc30> error: no socket error: Unable to create socket: Too many open files

ERROR                rtspsrc gstrtspsrc.c:6349:gst_rtspsrc_prepare_transports: failed to allocate udp ports

WARN                 rtspsrc gstrtspsrc.c:6896:gst_rtspsrc_setup_streams:<rtspsrc12> error: Could not setup transport.

INFO        GST_ERROR_SYSTEM gstelement.c:1857:void gst_element_message_full(GstElement *, GstMessageType, GQuark, gint, gchar *, gchar *, const gchar *, const gchar *, gint):<rtspsrc12> posting message: Could not get/set 
settings from/on resource.

INFO        GST_ERROR_SYSTEM gstelement.c:1880:void gst_element_message_full(GstElement *, GstMessageType, GQuark, gint, gchar *, gchar *, const gchar *, const gchar *, gint):<rtspsrc12> posted error message: Could not get/set settings from/on resource.

ERROR                rtspsrc gstrtspsrc.c:7192:gst_rtspsrc_open_from_sdp:<rtspsrc12> setup failed

WARN                 rtspsrc gstrtspsrc.c:7408:gst_rtspsrc_open:<rtspsrc12> can't setup streaming from sdp

(<unknown>:755): GLib-ERROR **: Creating pipes for GWakeup: Too many open files

The crash happens after the 13th instance of "startPipeline()" is called. Once again, the issue doesn't happen when the app is run from Xcode, only when the standalone app is run. My current pipeline is set as:

gst.setPipeline("rtspsrc location=rtsp://admin:admin@" + IP + ":554/cam/realmonitor?channel=1&subtype=1 latency=0 ! rtpjpegdepay ! jpegdec ! queue2 ! decodebin ! videoconvert", OF_PIXELS_MONO, true, feedWidth, feedHeight);

I'm currently trying to tweak some of the pipeline parameters to see if some of them don't encounter the "too many files" issue but I'm stabbing in the dark a little bit.

adielfernandez commented 8 years ago

Found the issue. Turns out newer OSX versions (I'm on 10.11.3 El Capitan) limit how many files are allowed to be open to only 256. With all the different feeds and each gstreamer element opening and closing their own files the cap was about 12 cameras before the error popped up. And apparently, Xcode lifts this OSX restriction when run from within the IDE, which is mighty nice of it to do but not helpful in finding the issue.

If you run into this issue, you can increase the maximum number of open files for your system using launchd/launchctl. Below is a link on how to do it, make sure you visit the comments for making sure the system changes take effect.

Change max files in El Capitan: http://blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan/

I guess this isn't specifically a gstreamer issue, sorry for cluttering up the repo, Arturo!