Intermittent issue in which RPi HQ camera feed freezes

Camera model
Raspberry Pi High-Quality camera (attached to an RPi4).

What is the problem?
Most of the time, the video feed works perfectly fine. However, intermittently (usually 2-3 times per hour, but with no specific regular pattern), the camera feed stops (to be more specific, the display within Octoprint shows the last frame of the video feed, so it looks as if the video has paused). Ditto when viewed via octopi.local/webcam/, octopi.local/webcam/?action=stream, and octopi.local:8080.
All other parts of the Octoprint web interface continue to work properly, such as the GCode viewer, etc.
This has happened intermittently for almost a year (when I first switched over to using the HQ camera instead of the normal RPi camera)... I just never got around to submitting a bug report about it until now.
Refreshing the Octoprint web page did not resolve the issue (I had to reboot the entire RPi or SSH into it and manually restart the webcamd service to regain the video feed).

What did you already try to solve it?
I previously set up a work-around solution, which was to add a cron-job every five minutes to the Pi user's cron: */5 * * * * echo "mypasswordhere" | sudo -kS service webcamd restart
Obviously, this restarts the webcamd service every five minutes. Now, with this cron job running regularly, all I have to do is refresh the web browser when the glitch occurs and the video feed resumes, but I'm wondering if there might be a proper solution...

I started writing this post about a month ago, and then thought "I wonder if something has since been updated, I'll disable that cron task, update everything, and see if it still faults". I'm back now, a month later, and yes, it is still having this fault. The attached logs are from almost a month ago.

I have also tried (months ago) to boot Octoprint into safe mode, and replicated the issue there, both with and without the above cron job in effect.

The webcam feed freezing does not correlate with the webcamd service restarting every five minutes. Sometimes it can happen only a few minutes after booting the Octoprint RPi, sometimes it can stay up and running for 30-40 minutes before it freezes. As previously stated, this error occurs regardless of if I have that cron job to restart webcamd, so it's not caused by the cron job.

Logs (/var/log/webcamd.log, syslog, dmesg, ... no logs, no support)

Additional information about your setup (OctoPrint version, OctoPi version, ...)

  • OctoPrint v1.6.1, but this has been happening for a good year or so, across multiple versions.
  • OctoPi v0.17.0.
  • Raspberry Pi 4 Model B Rev 1.1 running Raspbian Buster. (as recently as yesterday, I ran apt-get update && apt-get upgrade, so all packages are up-to-date as well)
  • Original Prusa i3 Mk3S

Thanks in advance for any help provided.

Update 28th May 2023: I have just switched over to a new Raspberry Pi Camera Module v3 and updated to OctoPrint v1.9.0, and that combination is working (with some non-standard alterations to make it work). As such, I am no longer able to comment about this issue regarding the HQ Camera as I no longer use it.

1 Like

Hello,

looks like webcamd or processes feeding it reach a limit WRT available ressources. With a less demanding cam on a raspi3B I see that at times, apparently the number of clients consuming the video stream has an influence, too.

I never saw print problems though when that happens and you don't report any as well, so the real problem is avoided.

Your solution of restarting webcamd by cron looks a bit , erm, should I say: brutal? though. Slashing all those daemons even when they didn't do any bad...

I have an entry in my config.yaml which adds an entry "Restart Webcam" to the system menu:


system:
  actions:
  - action: restartwebcam
    command: sudo systemctl restart webcamd
    confirm: You are about to restart the webcam
    name: Restart Webcam

I took those lines from a thread here some months ago and reading your post thought you might have a use for it - I never did until now except once for testing. When the stream freezes I close monitor in cura or check my browsers...

It's difficult to see from the webcamd log provided (since it is restarting so often) - when the stream freezes, does it log anything there? Is anything (errors etc.) logged to dmesg immediately after the freeze? Probably the best way to check is to let it freeze then take a look, trying to see if the system thinks everything is OK or not.

DaveTSG - did you ever get a fix to this problem? I see the same thing with an HQ camera. I am doing the same brute force by restarting webcamd, but would like to know if there is an official fix somewhere. Thanks.

Nope, still happening.

The output of dmesg is already in the OP.

I'm hitting the same issue on pi model 4 with HQ camera. I am not 100% sure but I am correlating this with touching the ribbon cable or moving/touching the camera, although it does not happen every time, and it also happens without me doing anything.

Restarting webcamd as suggested will fix it for anywhere between 5 minutes to 2 hours.

Wondering if we have defective hardware on our hands?

Same issue, but my camera is mostly remote and therefore not due to touching the cable.