ayufan / camera-streamer

High-performance low-latency camera streamer for Raspberry PI's
314 stars 47 forks source link

After the latest updates to `libcamera` and `libcamera-apps`, USB communication fails very often #88

Open FacuM opened 1 year ago

FacuM commented 1 year ago

I've recently switched to libcamera on tag release-v0.0.5+83-bde9b04f and libcamera-apps on tag v1.2.1, although compiling from any tag combination doesn't seem to help for some reason. Perhaps it's a hardware problem on my side?

On dmesg I'm getting the following error logged: dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted

Here's the log section prior to the issue:

[   64.676457] IPv6: ADDRCONF(NETDEV_CHANGE): vetheeb9eb9: link becomes ready
[   64.676736] br-187e6a0458ae: port 14(vetheeb9eb9) entered blocking state
[   64.676800] br-187e6a0458ae: port 14(vetheeb9eb9) entered forwarding state
[   64.985823] eth0: renamed from veth4744c2c
[   65.011422] IPv6: ADDRCONF(NETDEV_CHANGE): veth47d3748: link becomes ready
[   65.011706] br-187e6a0458ae: port 16(veth47d3748) entered blocking state
[   65.011790] br-187e6a0458ae: port 16(veth47d3748) entered forwarding state
[   99.607267] loop5: detected capacity change from 0 to 8
[ 5372.417276] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted
[ 5372.424202] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted
[10493.560531] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted
[22497.991969] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted
[23569.273313] br-187e6a0458ae: port 17(vethf73dab9) entered disabled state
[23569.274756] veth6325eea: renamed from eth0
[23569.722516] br-187e6a0458ae: port 17(vethf73dab9) entered disabled state
[23569.731200] device vethf73dab9 left promiscuous mode
[23569.731243] br-187e6a0458ae: port 17(vethf73dab9) entered disabled state
[23577.792530] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted
[23577.800104] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted
[23577.812259] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted
[23577.847645] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted

I've also enabled log-debug, log-verbose and log-stats in order to check if I could help any contributors figure out what could be wrong. FYI: The application runs on a container, so that's why you'll be seeing a prefix at the left of each line referring to the container name.

Here's said full streamer.log.

The weird thing is that I'm neither seeing any weird behavior in regards to the streamer itself (at least nothing weird is being logged to console) nor I'm able to pick up any specific errors or warnings in the vcdbg log.

Anyways, here's the vcdbg.log file, just in case you find it useful.

I'm running Ubuntu Server 22.04.2 LTS, this is how I build the project and this is how I run the binary.

As a side note, the issue started happening with a Microsoft Lifecam HD-5001 but I've now switched to a known-working generic Chinese camera (Microdia Integrated Camera), so I think it's safe to say this has nothing to do with the specific camera hardware.

Sometimes, the server throws a 500 (still, no errors in the console) and, at other times, it simply seems to be sort of restarting the whole device? Please, check this video, see how the exposure goes up and down constantly, as if the sensor were resetting (this is a timelapse generated by calling /?action=snapshot repeatedly and combining the output), check the example below. The /?action=snapshot endpoint does work sometimes, however, /?action=stream does cut-off repeteadly and requires a page reload to work for a couple more seconds until it hangs again.

HM2300D_GalaxyZFold4_Stand_v2_64bb20301259d6.01286879_0_0.webm

As I was previously building everything straight off master, I'm not entirely sure which combination of libcamera, libcamera-apps and camera-streamer worked properly, but as a rough guess, about a month ago it used to work fine.

I hope you can help me sort this out, if you need any additional information or testing, please let me know.