Pipewire using 100% of 1 cpu constantly Ubuntu 22.04.1

We will check this issue on our side, thanks for your feedback.

pipe wire still not provided as default audio system for pulseaudio replacement

any way can ask google about this issues and get many similar problem and how can solve it

I am also facing this problem.

I’ve also just noticed this issue has arisen on the latest Ubuntu 22.04 build

Hello @deepvim @Shazam1990 @Electr1

Not know much about pipewire, do we need this?

I will try to build Ubuntu image for vim4 without this package in the list to see if it working properly.

Manually removing the pipewire package breaks the desktop.

@numbqq not sure its needed, but i understand it comes with Ubuntu as standard. I have tried to kill the process for pipewire but it just comes back again. i hope a solution can be found to fix or remove this because having 1 CPU core at 100% 24/7 is not good

I followed the instructions here: https://ubuntuhandbook.org/index.php/2022/04/pipewire-replace-pulseaudio-ubuntu-2204/.

It does say that it won’t work on all devices and not to try it on a live system but I had to try it and ended up with an unusable installation.

I rolled back to a backup and the device was back to how it was.

However, I did an update the next day and it wiped out some of my customisations. After all the problems I’ve encountered, that was the straw that broke the camel’s back and I’m gonna get rid of the thing now.

Hello @technodevotee @Shazam1990 @Electr1 @ps23Rick @deepvim

I try to fix this issue on my side, I don’t know much about pipewire, so I disable the pipewire service, I’m not sure whether it will cause other issues, but it seems no 100% CPU for pipewire now.

Here are the steps I did:

sudo systemctl disable --global pipewire
sudo reboot

Can you also check on your side?

3 Likes

@numbqq i have tested what you suggested, and so far i see no problems after disabling pipewire.

1 Like

There is no pipewire service error now, but still has 100% load for 1 cpu. Haven’t find the reason now.

khadas@Khadas:~$ systemctl --user  status pipewire --no-pager 
● pipewire.service - PipeWire Multimedia Service
     Loaded: loaded (/usr/lib/systemd/user/pipewire.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-10-25 04:01:46 UTC; 1min 28s ago
TriggeredBy: ● pipewire.socket
   Main PID: 1866 (pipewire)
      Tasks: 2 (limit: 7760)
     Memory: 2.7M
        CPU: 1min 28.202s
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/pipewire.service
             └─1866 /usr/bin/pipewire

Oct 25 04:01:46 Khadas systemd[1859]: Started PipeWire Multimedia Service.

Perhaps the systemd task has very high preset priority ? maybe check the nice value of it and change to something lower in priority.

This is a bug in the vim4 driver for amlvideo2

Details

I just installed Ubuntu on my VIM4 and am hitting this issue, too. Running strace -p $(pidof pipewire) shows that the process appears to be in an infinite loop trying to enumerate video formats for attached cameras (note that I DO NOT have any cameras connected):

ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305193, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305194, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305195, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305196, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0
ioctl(74, VIDIOC_ENUM_FRAMESIZES, {index=103305197, pixel_format=v4l2_fourcc('R', 'G', 'B', 'R') /* V4L2_PIX_FMT_RGB565X */, type=0 /* V4L2_FRMSIZE_TYPE_??? */}) = 0

Looking at ls -l /proc/$(pidof pipewire)/fd, fd 74 is pointing to /dev/video11. According to v4l2-ctl, this is an amlvideo2. Querying the supported formats using v4l2-ctl -d /dev/video11 --list-formats-ext results in… an infinite loop! Specifically, it looks like the driver claims the following formats are supported:

    [0]: 'RGBR' (16-bit RGB 5-6-5 BE)
    [1]: 'RGB3' (24-bit RGB 8-8-8)
    [2]: 'BGR3' (24-bit BGR 8-8-8)
    [3]: 'RGB4' (32-bit A/XRGB 8-8-8-8)
    [4]: 'NV12' (Y/CbCr 4:2:0)
    [5]: 'NV21' (Y/CrCb 4:2:0)
    [6]: 'YU12' (Planar YUV 4:2:0)
    [7]: 'YV12' (Planar YVU 4:2:0)

However, upon enumerating them, the driver reports that the number of formats for 565 is ZERO! This is probably an unchecked edge case, but is still invalid behavior for the driver according to the v4l2 spec. The fix is to skip reporting those format types as supported, or better yet, skip starting the driver if there is no camera connected to the board.

The simplest fix is to patch the driver to return EINVAL when the VIDIOC_ENUM_FRAMESIZES ioctl is invoked for formats with invalid indices. This is the recommended return value for out-of-bounds index access, and is how the v4l2 utility code determines when to exit the enumeration loop.

2 Likes

Hello @MooseBoys

Thanks for your information. We will check the driver issue.

Found a workaround, too - sudo nano /usr/share/pipewire/pipewire.conf and comment out the line for v4l2 support, i.e. # api.v4l2.* = v4l2/libspa-v4l. Then reboot.

2 Likes

hi, we need it please, it’s the planned better replacement for pulseaudio AND JACK for serious audio users

I have no vim4 but I but care about pipewire working ok ubuntu on VIM2L and VIM1

Hello @MooseBoys @ravelo

I already have a patch to fix this issue. Need to update the kernel.

cd /tmp
wget https://dl.khadas.com/.test/linux-dtb-amlogic-5.4_1.3.1_arm64.deb
wget https://dl.khadas.com/.test/linux-image-amlogic-5.4_1.3.1_arm64.deb
sudo dpkg -i linux-dtb-amlogic-5.4_1.3.1_arm64.deb linux-image-amlogic-5.4_1.3.1_arm64.deb
sync
sudo reboot

Awesome, that fixed it! pipewire seems to be reporting errors now, but at least they seem to be handled correctly and avoid an infinite loop:

Dec 01 09:37:14 vim4 pipewire[4785]: spa.v4l2: '/dev/video34' VIDIOC_QUERYCTRL: Inappropriate ioctl for dev>
Dec 01 09:37:14 vim4 pipewire[4785]: spa.v4l2: '/dev/video34' VIDIOC_ENUM_FRAMESIZES: Inappropriate ioctl f>
...

@numbqq Are there any new updates for the v4l2 driver? This has been working for me for the most part, but I’m seeing the driver die after about 8 days of uptime, which causes my USB webcam to stop working:

[662584.949780] [19]: v4ldec has been destroyed.
[662584.950414] vdin-v4l: vdin_v4l2_open err:vdin v4l mode not enabled
[662584.951034] vdin-v4l: vdin_v4l2_open err:vdin v4l mode not enabled
[662584.951629] v4lvid: dbg: v4lvideo open
[662584.951672] v4lvid: dbg: vidioc_close!!!!
[662584.952117] v4lvid: dbg: v4lvideo open
[662584.952156] v4lvid: dbg: vidioc_close!!!!
.... (repeats forever)