Integrated Webcam stops working after few seconds [Ubuntu 16.04]

Read the edit below as well!

So it seems that there are many other who face(d) the error -71 problem; not only with webcams, but USB devices in general. The issue appears to be "a USB bug that was introduced with the power-saving modules [in kernel 2.6.27]". So in order to save power I guess, the webcam got shut down after a minute or so.

That website also has what appears to be the working solution:

$ sudo -s
$ echo -1> /sys/module/usbcore/parameters/autosuspend

This is written down to be the 'hotfix', but it seemed to have permanently solved my problem (after reboot the value changed back to the original value 2, but hey no more webcam failures :) )

Just to be sure, I also did the 'permanent fix':

  1. Create a file in /etc/modprobe.d called usbcore
  2. Populate the file with the following options usbcore autosuspend=-1
  3. Save the file
  4. Run "mkinitrd" (If you are sure that no USB device modules are loaded via the initrd, then you can skip this step). I skipped this step, because this command couldn't be found.
  5. Reboot

Hope this helps someone!

Important Edit!

So the above mentioned way to set the autosuspend is not universal, and depends on your OS. Please find a more elaborate answer on how to edit your autosuspend parameter here: https://unix.stackexchange.com/questions/91027/how-to-disable-usb-autosuspend-on-kernel-3-7-10-or-above

I will mention it here just for completeness.

For Ubuntu 14.04 & 15.04:

Edit the /etc/default/grub file and change the GRUB_CMDLINE_LINUX_DEFAULT line to add the usbcore.autosuspend=-1 option:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1"

Note that quit splash were already present options. So keep other options you have too.

After save the file, update grub:

sudo upgrade-grub
(might also be sudo update-grub2 (I did both))

And reboot.

Now check autosuspend value:

cat /sys/module/usbcore/parameters/autosuspend And it should display -1

Ubuntu 15.10 and above

The procedure is the same, but the param to change is autosuspend_delay_ms (instead of autosuspend).

Edit 2

False alarm... So the above didn't work after all. I still get that the USB device errors out on error -71. Here is a complete stack trace of /var/log/kern.log at the moment the webcam crashed: https://pastebin.com/8qHpBcdR. One note though: the first time the webcam crashes I get this kind of output: https://pastebin.com/XVwSEDBZ, The error -71 happens only after I try to run cheese again (which can launch normally). When it crashes again, it cannot work at all anymore (until I reboot).

If anyone has a clue what I can do, please let me know!

Edit 3

So I updated my kernel from 4.8.0-54-generic to 4.10.0-22-generic, and so far it seems to be stable. If it crashes again I will report it.


Ok, so the real solution to the problem was me working with a non-supportive kernel for my webcam. I upgraded from 4.8.0-54-generic to 4.10.0-22-generic, and the webcam is very stable now. Only a few times it will turn itself off (like on Facebook messenger for example), but just restarting the application will fix that. No need to reboot anymore.