After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 777354 - v4l2src: Doesn't Stop After Device Removed
v4l2src: Doesn't Stop After Device Removed
Status: RESOLVED NOTGNOME
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
unspecified
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-01-16 19:53 UTC by Casey Zahorik
Modified: 2017-03-05 15:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
dmesg log (63.25 KB, text/plain)
2017-01-24 01:14 UTC, Casey Zahorik
Details
gst log (220.36 KB, text/plain)
2017-01-24 01:15 UTC, Casey Zahorik
Details

Description Casey Zahorik 2017-01-16 19:53:06 UTC
Versions: 1.10.2 and 10.8.3 (probably versions after as well)

Pipeline: gst-launch-1.0 v4l2src device=/dev/video0 ! fakesink 

Problem: When the usb device providing the video for /dev/video0 is unplugged, gstreamer doesn't crash or detect the device has been unplugged and stop. This causes the device, when plugged back in, to re-enumerate as another device instead of having the same path as before. 

This is not a problem when using older versions of gstreamer/v4l2. I have tried it on 1.2 and 1.4, both work as expected.
Comment 1 Arun Raghavan 2017-01-17 13:52:20 UTC
With both GStreamer 1.10.2 and master, I see the following on unplugging the USB webcam:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not read from resource.
Additional debug info:
../subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c(1058): gst_v4l2_buffer_pool_poll (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
poll error 1: Invalid argument (22)
Execution ended after 0:00:02.480060856
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
Comment 2 Nicolas Dufresne (ndufresne) 2017-01-17 17:11:06 UTC
Can you provide a trace of when it keeps running for you ? Use a pipeline similar to this one and attach the gst.log file please.

GST_DEBUG="2,v4l2*:6" gst-launch-1.0 v4l2src ! fakesink 2> gst.log
Comment 3 Casey Zahorik 2017-01-24 01:14:39 UTC
Created attachment 344077 [details]
dmesg log
Comment 4 Casey Zahorik 2017-01-24 01:15:09 UTC
Created attachment 344078 [details]
gst log
Comment 5 Casey Zahorik 2017-01-24 01:16:41 UTC
sudo GST_DEBUG="2,v4l2*:6" gst-launch-1.0 v4l2src device=/dev/video0 ! fakesink 2> gst.log

Produced the results above. 
1) started the above command as well as logged dmesg
2) unplugged device
3) waited ~10 sec and plugged back in
4) killed gst instance with ctrl-c

Let me know if you need any additional information.

Thanks!
Comment 6 Nicolas Dufresne (ndufresne) 2017-01-24 01:55:20 UTC
Comment on attachment 344077 [details]
dmesg log

Something in the driver cleanup didn't go well.

[  277.301723] sysfs group ffffffffb7ad04a0 not found for kobject 'media0'
Comment 7 Nicolas Dufresne (ndufresne) 2017-01-24 01:59:23 UTC
And GStreamer endup waiting fro more then 20 seconds (before CTRL+C) for the driver to give sign of life inside gst_v4l2_buffer_pool_poll().

This all looks like a nasty kernel bug to me. Nothing we can do from usespace point of view. Maybe try with another V4L2 client, to see what happens ?
Comment 8 Casey Zahorik 2017-01-24 18:54:56 UTC
We are looking at video0 not media0, though i guess they might be the same device. I have unfortunately tried the version of v4l2 that comes with ubuntu 16 lts and the newest stable build of it from their website directly with the same results. Would you have any other suggestions? Thanks!
Comment 9 Nicolas Dufresne (ndufresne) 2017-01-24 19:09:03 UTC
(In reply to Casey Zahorik from comment #8)
> We are looking at video0 not media0, though i guess they might be the same


/dev/media0 in your case is most likely the topology of the UCV Driver. Try:

  sudo media-ctl -p /dev/media0

To see the topology. Most likely the entity 1 will match /dev/video0. The error in the log gives me the impression the kernel fails somehow, leaking a reference or something, which leads to the topology still being active. 

> device. I have unfortunately tried the version of v4l2 that comes with
> ubuntu 16 lts and the newest stable build of it from their website directly
> with the same results. Would you have any other suggestions? Thanks!

You may try with vlc or mplayer, to see what happens. But I have doubt there is anything wrong with GStreamer here.

  vlc v4l2://
  mplayer tv://
Comment 10 Nicolas Dufresne (ndufresne) 2017-03-05 15:12:10 UTC
Marking as not a GStreamer bug, as there is indication that the kernel is at fault here.