andreknieriem / photobooth

A photobooth Web-Application for raspberry pi with gphoto2
https://photobooth.andrerinas.de/
MIT License
294 stars 163 forks source link

device cam preview broken after upgrade from 2.x version #296

Closed black-snake closed 2 years ago

black-snake commented 2 years ago

Describe the bug After I upgraded to the latest version by git checkout origin/master the device preview (Raspberry Camera v2) does not longer work. Even a reset of the settings (also tried reset-raspbian.sh) does not fix the issue.

To Reproduce Steps to reproduce the behavior:

  1. Upgrade via https://github.com/andreknieriem/photobooth/wiki/Update-Photobooth
  2. Try to take a picture in Chromium with exception in unsafely-treat-insecure-origin-as-secure. (preview picture not displayed, only countdown, no asking for permission to access webcam by Chromium)

Expected behavior A preview from the device cam is displayed. Chromium asks for permission to access webcam.

Screenshots N/A

Environment (please complete the following information):

Photobooth

Additional context N/A

andi34 commented 2 years ago

Might be fixed by https://github.com/andi34/photobooth/commit/aa0189f98f78cda78eb136afec74c4248f841880

black-snake commented 2 years ago

Thanks for the reply. I finally found the issue! It‘s been the latest version of Chromium (v92) which causes the device camera access to stop working. From this version of Chromium on, my Raspberry Pi Cam v2 is no longer recognized as camera by the browser. I will file a respective issue for Chromium.

HBTphoto commented 2 years ago

Thanks for the reply. I finally found the issue! It‘s been the latest version of Chromium (v92) which causes the device camera access to stop working. From this version of Chromium on, my Raspberry Pi Cam v2 is no longer recognized as camera by the browser. I will file a respective issue for Chromium.

Hi, maybee i have the same issue, could you share me the for the chromium issue ? Do you solve it ?

black-snake commented 2 years ago

Sorry for the late answer, I am a bit short of time at the moment.

Could be that you have the same issue because it happened to me on a fresh and clean installation of Raspbian with the mentioned version of Chromium. However, I did not have the time to file a bug at the Chromium project. I mean, this must be prepared, you somehow need information on the environment, used versions, and steps to reproduce (if possible at all in this case). If you have the time and can make the effort, I really appreciate filing a bug and share the link.

What’s more, I experienced with the previous version of Chromium (don’t know exact version string now but it is the predecessor of the current one), Chromium intermittently and unexpectedly closes after a certain time. I don’t know if it’s a memory leak or any other kind of crash. Anyway, this is really annoying and you should really test your installation properly before you bring your PhotoBooth to any event.

Domanaik commented 2 years ago

@black-snake can you confirm on which older version is was running for sure? Im currently using v90.0.4430.212 and it looks like I have the same problem.

andi34 commented 2 years ago

Hey again! In the meantime I did some research and think this could be a Kernel bug.

https://github.com/hisenyiu2015/msm-4.14/commit/fc02ed828d2910e5431526b60eece09a4a74d26c

On 5.10 https://github.com/raspberrypi/linux/blob/30bb91977d65c22cec3eaeadb06a6ff7f36ecbc5/drivers/media/platform/bcm2835/bcm2835-unicam.c#L121-L122

Anybody knows when the issue started?

There have been many changes made in the meantime inside the kernel source.

A dmesg might help finding an issue, also someone could try adapting mentioned commit and build a own Kernel and test. Currently I am busy in privat live and not sure when to find time to.

Steps to building a own Kernel: https://www.raspberrypi.com/documentation/computers/linux_kernel.html

black-snake commented 2 years ago

@black-snake can you confirm on which older version is was running for sure? Im currently using v90.0.4430.212 and it looks like I have the same problem.

Hey, I currently don’t have access to my photo booth, so I can tell you the exact version of chromium at the moment. However, I used pi apps to downgrade chromium. Take a look at these links below:

You downgrade version by version starting from the newest one and test each version for camera functionality.

@andi34 I don’t know if it’s a kernel issue — could be. Yet, at the time of writing my original post, I upgraded the system to all newest available versions (including the kernel) and I experienced that the camera worked in chromium when I downgraded chromium only.

I am a bit short of time at the moment so I’m sorry that I can’t go into more detail at this point. But please keep us posted on what you tried and what might have solve the issue.

Domanaik commented 2 years ago

I tested it with Piapps > Downgrade Chromium to v88 and its working again. Thanks for the help!

black-snake commented 2 years ago

I tested it with Piapps > Downgrade Chromium to v88 and its working again. Thanks for the help!

Great to hear, could you maybe file a chromium issue?

andi34 commented 2 years ago

(...) Now you've explained that you are on buster it all makes a bit more sense. Buster does have a working camera V4L2 layer and v88 works with that, something got broken in Chrome after that going to v92 (probably "better" size checking), but then bullseye came out and the policy decision was that new versions of Chrome would only be ported to bullseye (it was getting to be an increasing pain to get a compatible lib set to compile on buster), buster would get the base debian port which doesn't have my V4L2 size kludge in it (v95 bullseye does). This decision does have the unfortunate side effect that, as the V4L2 camera driver is bust in bullseye (or it was last I looked - it may have got better) and libcamera is currently problematic that Pi camera support is bust everywhere :-( That isn't a helpful response I know, but I believe it to be a statement of where we are.

So there's only the way of self-compiling chromium to use a newer version than v88. I'll try to dig into it if I find enough time.

black-snake commented 2 years ago

Thank you so much for engaging yourself into that. As soon as I have the time, I will try this with a fresh bullseye version of Raspbian and the latest version of Chromium.

black-snake commented 2 years ago

So, I just conducted some research with the following setup:

Here are my findings:

  1. By default, the new Raspbian distribution comes with libcamera as a replacement for raspistill (libcamera is incompatible with the way raspistill works).
  2. When I started Chromium with a fresh updated installation relying on libcamera, Chromium asked for permission to access the camera but I couldn't get video from the camera to be displayed. So I went a more basic approach and tried to use libcamera-hello as test preview to see if the camera is detected and works in general. This fails with an error something like failed to import fd 19 -- same for libcamera-still -o test.jpeg. Yet, libcamera-still -o test.jpeg -n (-n is for no preview) works. I googled the error but couldn't find any solution which worked to resolve the issue. It seems this is something related to the video driver because it does work without displaying (previewing) the camera image(s).
  3. I switched to legacy camera interface via sudo raspi-config and got it working in Chromium instantaneously. Also raspistill works. However, raspistill and its variants are deprecated. So this does not seem to be a very future-proof way.

I can't understand why libcamera-hello does not work out-of-the-box with a fresh and clean installation of Raspbian using the original Raspberry Pi Camera v2.

Anyways, I you can live with the legacy interface for the camera, you're good to go with Raspbian (Bullseye) and the current version of Chromium.

andi34 commented 2 years ago

Thanks for your feedback!

The information I got sounds like there's still problems with the driver on bullseye

(...) as the V4L2 camera driver is bust in bullseye (or it was last I looked - it may have got better) and libcamera is currently problematic that Pi camera support is bust everywhere :-( (...)

andi34 commented 2 years ago

Just to mention: For Pi Camera you might need a dtoverlay to be set manually (on Pi3 and older from whats written here https://pi-buch.info/fotos-und-videos-mit-den-libcamera-tools-aufnehmen/). Also see: https://www.raspberrypi.com/documentation/accessories/camera.html#if-you-do-need-to-alter-the-configuration

andi34 commented 1 year ago

Downgrade Chromium on Buster

wget "http://archive.raspberrypi.org/debian/pool/main/c/chromium-browser/chromium-browser_88.0.4324.187-rpt1_armhf.deb"
wget "http://archive.raspberrypi.org/debian/pool/main/c/chromium-browser/chromium-codecs-ffmpeg-extra_88.0.4324.187-rpt1_armhf.deb"
sudo apt install --no-install-recommends --allow-downgrades --allow-change-held-packages ./chromium-browser_88.0.4324.187-rpt1_armhf.deb ./chromium-codecs-ffmpeg-extra_88.0.4324.187-rpt1_armhf.deb
sudo apt-mark hold chromium-browser chromium-codecs-ffmpeg-extra