pikvm / ustreamer

µStreamer - Lightweight and fast MJPEG-HTTP streamer
https://pikvm.org
GNU General Public License v3.0
1.73k stars 239 forks source link

CAP: Can't release HW buffer=1 (skipped frame): Cannot allocate memory #268

Open breakingflower opened 8 months ago

breakingflower commented 8 months ago

I'm getting the following on an RPI zero 2w and camera v3 noir: Device:

Steps to reproduce:

It seems there is something happening with releasing memory. When I open the stream page I notice the first seconds images are changing, then the module breaks & starts errorring and can't restore itself.

breakingflower commented 8 months ago

Specifically this is repeating:

================================================================================
-- DEBUG [526.135          ] -- CAP: Opening capture device ...
-- DEBUG [526.136          ] -- CAP: Capture device fd=8 opened
-- DEBUG [526.136          ] -- CAP: Querying device capabilities ...
-- INFO  [526.136          ] -- CAP: Using capture type: single-planar
-- INFO  [526.136          ] -- CAP: Using input channel: 0
-- DEBUG [526.136          ] -- CAP: Using TV standard: DEFAULT
-- DEBUG [526.136          ] -- CAP: Probing device format=YUYV, stride=1280, resolution=640x480 ...
[0:08:46.137992840] [2993]  INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-YUYV
[0:08:46.139052634] [2984]  INFO RPI vc4.cpp:611 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 1536x864-SBGGR10_1X10 - Selected unicam format: 1536x864-pBAA
-- INFO  [526.141          ] -- CAP: Using resolution: 640x480
-- INFO  [526.141          ] -- CAP: Using format: YUYV
-- DEBUG [526.141          ] -- CAP: Querying HW FPS ...
-- INFO  [526.142          ] -- CAP: Querying HW FPS changing is not supported
-- INFO  [526.142          ] -- CAP: Using IO method: MMAP
-- DEBUG [526.142          ] -- CAP: Requesting 5 device buffers for MMAP ...
[0:08:46.142377586] [2993]  INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-YUYV
[0:08:46.143375035] [2984]  INFO RPI vc4.cpp:611 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 1536x864-SBGGR10_1X10 - Selected unicam format: 1536x864-pBAA
-- INFO  [526.154          ] -- CAP: Requested 5 device buffers, got 5
-- DEBUG [526.154          ] -- CAP: Allocating device buffers ...
-- DEBUG [526.154          ] -- CAP: Calling us_xioctl(VIDIOC_QUERYBUF) for device buffer=0 ...
-- DEBUG [526.154          ] -- CAP: Mapping device buffer=0 ...
-- DEBUG [526.154          ] -- CAP: Calling us_xioctl(VIDIOC_QUERYBUF) for device buffer=1 ...
-- DEBUG [526.154          ] -- CAP: Mapping device buffer=1 ...
-- DEBUG [526.154          ] -- CAP: Calling us_xioctl(VIDIOC_QUERYBUF) for device buffer=2 ...
-- DEBUG [526.154          ] -- CAP: Mapping device buffer=2 ...
-- DEBUG [526.154          ] -- CAP: Calling us_xioctl(VIDIOC_QUERYBUF) for device buffer=3 ...
-- DEBUG [526.154          ] -- CAP: Mapping device buffer=3 ...
-- DEBUG [526.154          ] -- CAP: Calling us_xioctl(VIDIOC_QUERYBUF) for device buffer=4 ...
-- DEBUG [526.154          ] -- CAP: Mapping device buffer=4 ...
-- DEBUG [526.155          ] -- CAP: Calling us_xioctl(VIDIOC_QBUF) for buffer=0 ...
-- DEBUG [526.155          ] -- CAP: Calling us_xioctl(VIDIOC_QBUF) for buffer=1 ...
-- DEBUG [526.155          ] -- CAP: Calling us_xioctl(VIDIOC_QBUF) for buffer=2 ...
-- DEBUG [526.155          ] -- CAP: Calling us_xioctl(VIDIOC_QBUF) for buffer=3 ...
-- DEBUG [526.155          ] -- CAP: Calling us_xioctl(VIDIOC_QBUF) for buffer=4 ...
-- DEBUG [526.155          ] -- CAP: Exporting device buffer=0 to DMA ...
-- DEBUG [526.155          ] -- CAP: Exporting device buffer=1 to DMA ...
-- DEBUG [526.155          ] -- CAP: Exporting device buffer=2 to DMA ...
-- DEBUG [526.155          ] -- CAP: Exporting device buffer=3 to DMA ...
-- DEBUG [526.155          ] -- CAP: Exporting device buffer=4 to DMA ...
-- INFO  [526.288          ] -- CAP: Capturing started
-- DEBUG [526.289          ] -- Preparing M2M-IMAGE encoder ...
-- INFO  [526.289          ] -- Using JPEG quality: 80%
-- INFO  [526.289          ] -- Creating pool JPEG with 4 workers ...
-- DEBUG [526.289          ] -- Hello! I am a worker jw-0 ^_^
-- DEBUG [526.289          ] -- Worker jw-0 waiting for a new job ...
-- DEBUG [526.289          ] -- Hello! I am a worker jw-1 ^_^
-- DEBUG [526.290          ] -- Worker jw-1 waiting for a new job ...
-- DEBUG [526.290          ] -- Hello! I am a worker jw-2 ^_^
-- DEBUG [526.290          ] -- Worker jw-2 waiting for a new job ...
-- DEBUG [526.290          ] -- Hello! I am a worker jw-3 ^_^
-- DEBUG [526.290          ] -- Worker jw-3 waiting for a new job ...
-- INFO  [526.291          ] -- Capturing ...
-- DEBUG [526.291          ] -- CAP: Calling select() on video device ...
-- DEBUG [526.312          ] -- CAP: Device select() --> 1; has_read=1, has_error=0
-- DEBUG [526.312          ] -- CAP: Grabbing hw buffer ...
[0:08:46.312238065] [2993] ERROR V4L2Compat v4l2_camera_proxy.cpp:680 Failed to clear eventfd POLLIN
[0:08:46.312384419] [2993] ERROR V4L2Compat v4l2_camera_proxy.cpp:680 Failed to clear eventfd POLLIN
[0:08:46.312469628] [2993] ERROR Request request.cpp:472 FrameBuffer already set for stream
[0:08:46.312518118] [2993] ERROR V4L2Compat v4l2_camera.cpp:259 Can't set buffer for request
-- ERROR [526.313          ] -- CAP: Can't release HW buffer=1 (skipped frame): Cannot allocate memory
-- INFO  [526.391          ] -- Destroying workers pool JPEG ...
-- DEBUG [526.392          ] -- Bye-bye (worker jw-0)
-- DEBUG [526.392          ] -- Bye-bye (worker jw-1)
-- DEBUG [526.393          ] -- Bye-bye (worker jw-2)
-- DEBUG [526.393          ] -- Bye-bye (worker jw-3)
-- DEBUG [526.393          ] -- CAP: Calling VIDIOC_STREAMOFF ...
-- DEBUG [526.407          ] -- CAP: Releasing HW buffers ...
-- INFO  [526.410          ] -- CAP: Capturing stopped
================================================================================
mdevaev commented 8 months ago

It seems this is a problem inside libcamerify. I recommend to address it to its developers.

davhenriques commented 5 months ago

I am have the same hardware and having the same issue. Have you found any solution yet?

mdevaev commented 4 months ago

Try sudo modprobe bcm2835-v4l2 and then start ustreamer via libcamerify.