Bug 782627 - Cheese starts slowly
Cheese starts slowly
Status: NEW
Product: cheese
Classification: Applications
Component: general
3.26.x
Other Linux
: Normal normal
: ---
Assigned To: Cheese Maintainer(s)
Cheese Maintainer(s)
:
: 788749 (view as bug list)
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2017-05-14 18:11 UTC by Martin
Modified: 2017-12-06 11:39 UTC (History)
7 users (show)

See Also:
GNOME target: ---
GNOME version: 3.23/3.24


Attachments
monitor: Implement GAsyncInitable interface (6.28 KB, patch)
2017-11-02 09:14 UTC, Ondrej Holy
none Details | Diff | Review

Description Martin 2017-05-14 18:11:08 UTC
Ubuntu 17.04, Cheese 3.24, Logitech USB Webcam C270:

Starting cheese, it needs 35s until I see a picture.
STRACE shows that cheese is waiting 12s in a futex, and 75% of the time it is doing 3000 ioctls with /dev/video0.
Comment 1 Ondrej Holy 2017-06-23 08:06:15 UTC
Thanks for your bug report. Can you please try to downgrade the cheese and/or try with older kernel to see if it is caused by some recent cheese changes, or is a bug in kernel?
Comment 2 Ondrej Holy 2017-06-23 09:04:03 UTC
Just a note that it also affects user-accounts panel of gnome-control-center and Bug 783789 contains various debug info...
Comment 3 Ondrej Holy 2017-06-23 09:33:05 UTC
*** Bug 783789 has been marked as a duplicate of this bug. ***
Comment 4 Ondrej Holy 2017-06-26 08:11:05 UTC
I am not able to reproduce the slowdown even with an external webcam, however, it hangs completely with kernel-4.12.0-0.rc6.git3.1.fc27.x86_64 with the following backtrace (kernel-4.11.0-1.fc27.x86_64 works nicely): 

Thread 1 (Thread 0x7f55659cfac0 (LWP 5292))

  • #0 syscall
    at ../sysdeps/unix/sysv/linux/x86_64/syscall.S line 38
  • #1 g_cond_wait
    at gthread-posix.c line 1395
  • #2 gst_v4l2_device_provider_start
    at gstv4l2deviceprovider.c line 424
  • #3 gst_device_provider_start
    at gstdeviceprovider.c line 429
  • #4 gst_device_monitor_start
    at gstdevicemonitor.c line 506
  • #5 g_type_create_instance
    at gtype.c line 1866
  • #6 g_object_new_internal
    at gobject.c line 1781
  • #7 g_object_new_with_properties
    at gobject.c line 1949
  • #8 g_object_new
    at gobject.c line 1621
  • #9 cheese_camera_device_monitor_new
    at libcheese/cheese-camera-device-monitor.c line 304

So I suppose this is caused by kernel driver and thus NOTGNOME. Can somebody confirms it?
Comment 5 Baptiste Mille-Mathias 2017-06-26 18:48:21 UTC
I'm on f26 and I saw this problem 2 months ago at least (I can't remember when precisely). The current kernel is 4.11.6-301
Comment 6 JB Lallement 2017-10-20 09:36:38 UTC
I'm affected by this problem on Ubuntu Desktop 17.10 with a Logitech 9000 Pro

I downgraded cheese from 3.26.0-0ubuntu1 to 3.24.0-0ubuntu1 and the kernel from 4.13 to 4.11 to 4.10 without any difference.

IT takes roughly 34s to start with an external webcam and 4s with the internal webcam.

Strace shows that during startup cheese spends most of its time repeating this sequence with slight variations each time (fmt.pix differs)

1121  10:16:18.795096 ioctl(20, VIDIOC_ENUM_FRAMESIZES, {index=12, pixel_format=v4l2_fourcc('Y', 'U', 'Y', 'V'), type=V4L2_FRMSIZE_TYPE_DISCRETE, discrete={width=960, height=720}}) = 0
1121  10:16:18.795344 ioctl(20, VIDIOC_ENUM_FRAMEINTERVALS, {index=0, pixel_format=v4l2_fourcc('Y', 'U', 'Y', 'V'), width=960, height=720, type=V4L2_FRMIVAL_TYPE_DISCRETE, discrete=1/15}) = 0
1121  10:16:18.795870 ioctl(20, VIDIOC_ENUM_FRAMEINTERVALS, {index=1, pixel_format=v4l2_fourcc('Y', 'U', 'Y', 'V'), width=960, height=720, type=V4L2_FRMIVAL_TYPE_DISCRETE, discrete=1/10}) = 0
1121  10:16:18.796237 ioctl(20, VIDIOC_ENUM_FRAMEINTERVALS, {index=2, pixel_format=v4l2_fourcc('Y', 'U', 'Y', 'V'), width=960, height=720, type=V4L2_FRMIVAL_TYPE_DISCRETE, discrete=1/5}) = 0
1121  10:16:18.796593 ioctl(20, VIDIOC_ENUM_FRAMEINTERVALS, {index=3, pixel_format=v4l2_fourcc('Y', 'U', 'Y', 'V'), width=960, height=720}) = -1 EINVAL (Invalid argument)
1121  10:16:18.797045 ioctl(20, VIDIOC_CROPCAP, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, bounds={left=0, top=0, width=640, height=480}, defrect={left=0, top=0, width=640, height=480}, pixelaspect=1/1}) = 0
1121  10:16:18.797277 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_ANY, bytesperline=0, sizeimage=0, colorspace=0 /* V4L2_COLORSPACE_??? */} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:18.824205 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SMPTE170M} <unfinished ...>
1091  10:16:18.828646 <... poll resumed> ) = 0 (Timeout)
1091  10:16:18.828905 inotify_add_watch(14, "/home/j-lallement/Vid\303\251os/Webcam", IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) = -1 ENOENT (No such file or directory)
1091  10:16:18.829180 poll([{fd=4, events=POLLIN}, {fd=14, events=POLLIN}], 2, 3995 <unfinished ...>
1121  10:16:18.852812 <... ioctl resumed>  => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:18.853124 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SMPTE240M} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:18.881687 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_REC709} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:18.910255 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_470_SYSTEM_M} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:18.937660 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_470_SYSTEM_BG} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:18.964148 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_JPEG} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:18.992298 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:19.021039 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=0x9 /* V4L2_COLORSPACE_??? */} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:19.048770 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=0xa /* V4L2_COLORSPACE_??? */} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:19.077229 ioctl(20, VIDIOC_TRY_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=0xb /* V4L2_COLORSPACE_??? */} => fmt.pix={width=960, height=720, pixelformat=v4l2_fourcc('Y', 'U', 'Y', 'V'), field=V4L2_FIELD_NONE, bytesperline=1920, sizeimage=1382400, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
1121  10:16:19.104479 ioctl(20, VIDIOC_ENUM_FRAMESIZES, {index=13, pixel_format=v4l2_fourcc('Y', 'U', 'Y', 'V'), type=V4L2_FRMSIZE_TYPE_DISCRETE, discrete={width=1280, height=720}}) = 0
Comment 7 Martin 2017-10-20 09:45:01 UTC
With Ubuntu 17.10 on Wayland and Cheese 3.26 the Problem disappeared.
Do you use Wayland or Xorg?
Comment 8 JB Lallement 2017-10-20 09:54:37 UTC
I tried both and the result is the same. 34s to start with the external camera plugged in.
Comment 9 JB Lallement 2017-10-20 11:10:08 UTC
With gstreamer in debug mode I think the slowness comes from the enumeration of the capabilities of the camera. The external one supporting more format the enumeration is much slower. 
There is a similar issue with the account settings panel of gnome shell and it's slower to open with the webcam attached and again it's gstreamer spending time probing the video device.
Comment 10 Ondrej Holy 2017-11-02 09:14:09 UTC
Created attachment 362800 [details] [review]
monitor: Implement GAsyncInitable interface

Monitor initialization may block if external camera is conbected,
probably due to some kernel bug. It causes freezes for applications,
which is not acceptable. Let's implement GAsyncInitable interface,
so it can be initialized asynchronously.
Comment 11 Ondrej Holy 2017-11-02 11:38:31 UTC
*** Bug 788749 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.