You are not logged in.

#1 2022-10-22 22:09:24

kotv
Member
Registered: 2022-10-22
Posts: 4

[SOLVED] Audio/Videao stuttering/crackling, Firefox + PipeWire in VMs

Hi all,

I generally use the old pulseaudio backend.
I've created a VM with the latest archiso image.
During the installation I installed pipewire, pipewire-alsa, pipewire-jack, pipewire-pulse and wireplumber.

After I installed the whole system including KDE Plasma DE I launched Firefox and tried to play a random YouTube video. Video and audio start crackling/stuttering, make a terrible noise for few seconds (about 3-5) and stop playing with the loading symbol on top of the video.
The crackling is present even when any system sound is played.

Googling a bit I've read that this behavior is caused by the audio backend and read a lot of posts that suggest to edit the quantum settings in /etc/pipewire/pipewire.conf.

I tried all of these but nothing, the issue is still there. So I tried to uninstall pipewire and the issue is gone. What can I try to keep using pipewire?

Last edited by kotv (2022-10-23 23:09:49)

Offline

#2 2022-10-23 14:39:06

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,885

Re: [SOLVED] Audio/Videao stuttering/crackling, Firefox + PipeWire in VMs

Is rtkit installed? It's generally required for pipewire to get high priority for processing. Also which exact settings did you change how and did you restart pipewire properly after doing the changes? Also what are you using on the host, and does e.g. the sample rate between the virtual sound card and the sound card of your host match? I'd generally be wary of drawing conclusions based on a virtual environment. If you actually want to test pipewire install and test it on your host it's trivial to switch between it and pulseaudio.

Offline

#3 2022-10-23 20:43:32

kotv
Member
Registered: 2022-10-22
Posts: 4

Re: [SOLVED] Audio/Videao stuttering/crackling, Firefox + PipeWire in VMs

Hi V1del, thanks for your answer, I know nothing about audio

I've installed rtkit, nothing canged.

I tried editing the following lines in /etc/pipewire/pipewire.conf , I tried both lower and greater values:

default.clock.rate          = 48000
default.clock.allowed-rates = [ 48000 ]
default.clock.quantum       = 2048
clock.min-quantum   = 1024
clock.max-quantum   = 8192
clock.quantum-limit = 8192

I restart pipewire after every edit to the config file with:

systemctl --user restart pipewire pipewire-pulse && systemctl --user daemon-reload

This is the status of my pipewire.service

$ systemctl --user status pipewire
● pipewire.service - PipeWire Multimedia Service
    Loaded: loaded (/usr/lib/systemd/user/pipewire.service; enabled; preset: enabled)
    Active: active (running) since Sun 2022-10-23 21:41:07 CEST; 12min ago
TriggeredBy: ● pipewire.socket
Main PID: 3495 (pipewire)
    Tasks: 2 (limit: 9472)
    Memory: 5.3M
        CPU: 3.625s
    CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/pipewire.service
            └─3495 /usr/bin/pipewire

And this is what journalctl | grep pipewire says:

ott 23 04:42:51 Arch wireplumber[996]: disconnected from pipewire
ott 23 04:42:51 Arch systemd[740]: pipewire.service: Consumed 3.432s CPU time.
ott 23 14:32:18 Arch pipewire[970]: mod.rt: Can't find xdg-portal: (null)
ott 23 14:32:18 Arch pipewire[970]: mod.rt: found session bus but no portal
ott 23 14:32:25 Arch pipewire-pulse[1169]: mod.protocol-pulse: client 0x5633c30a8c80: send channel:4294967295 20, error -32: Pipe interrotta
ott 23 14:32:25 Arch pipewire-pulse[1212]: 536870912
ott 23 20:47:23 Arch wireplumber[971]: disconnected from pipewire
ott 23 20:47:23 Arch pipewire[970]: Asked to handle disabled watch: 0x559b9f566110 20Asked to handle disabled watch: 0x559b9f566110 20Asked to handle disabled watch: 0x559b9f566110 20
$ pacman -Qsq pipewire
kpipewire
pipewire
pipewire-alsa
pipewire-audio
pipewire-jack
pipewire-pulse
wireplumber
$ pacman -Qsq xdg
libcanberra
xdg-desktop-portal
xdg-desktop-portal-kde
xdg-user-dirs
xdg-utils

The host is Windows 11 and the audio card sampling rate is configured to 24bit, 48KHz, the Hypervisor is VmWare and the guest system has open-vm-tools installed

Last edited by kotv (2022-10-23 20:47:11)

Offline

#4 2022-10-23 22:13:31

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,885

Re: [SOLVED] Audio/Videao stuttering/crackling, Firefox + PipeWire in VMs

Mhm, likely pipewire/wireplumber does configure some too aggressive defaults, on a googler I've found https://gitlab.freedesktop.org/pipewire … al-machine try the suggestion there.

Offline

#5 2022-10-23 23:07:07

kotv
Member
Registered: 2022-10-22
Posts: 4

Re: [SOLVED] Audio/Videao stuttering/crackling, Firefox + PipeWire in VMs

Hi V1del,

thank you again. This solved the issue.

I'm gonna recap the steps I followed to solve this, just in case this could be useful to anyone.

Installed packages:

pacman -S pipewire pipewire-audio pipewire-pulse pipewire-alsa pipewire-jack wireplumber rtkit

Configuration file used:

#just copy the default file without edit it, maybe it's useless but I did it.
cp /usr/share/pipewire/pipewire.conf /etc/pipewire/

Plus followed the instructions posted by V1del, follow the whole Stuttering Audio in Virtual Machine section.

Make sure to restart pipewire and wireplumber with

systemctl --user restart wireplumber pipewire pipewire-pulse

This solved the issue for me, thanks again V1del

EDIT:

If anyone could be interested to do it inside a script or in a non interactive way use the following lines:

#Fix PipeWire crackling on VMs
sudo cp /usr/share/pipewire/pipewire.conf /etc/pipewire/
mkdir -p ~/.config/wireplumber/main.lua.d
cp /usr/share/wireplumber/main.lua.d/50-alsa-config.lua ~/.config/wireplumber/main.lua.d
sed -i "s/\[\"api.alsa.period-size\"\] = [[:digit:]]*/\[\"api.alsa.period-size\"\] = 1024/" ~/.config/wireplumber/main.lua.d/50-alsa-config.lua
sed -i "s/\[\"api.alsa.headroom\"\] = [[:digit:]]*/\[\"api.alsa.headroom\"\] = 8192/" ~/.config/wireplumber/main.lua.d/50-alsa-config.lua
#Fix PipeWire crackling with Fiefox (espacially in VMs)
sed -i "s/reader.parse-on-load.enabled\", true/reader.parse-on-load.enabled\", false/" $(find ~/.mozilla/firefox/ -name prefs.js)
sed -i "s/media.webspeech.synth.enabled\", true/media.webspeech.synth.enabled\", false/" $(find ~/.mozilla/firefox/ -name prefs.js)
systemctl --user restart wireplumber pipewire pipewire-pulse

Last edited by kotv (2022-10-28 10:06:47)

Offline

#6 2024-04-10 02:22:38

WulfgarPro
Member
Registered: 2011-01-27
Posts: 3

Re: [SOLVED] Audio/Videao stuttering/crackling, Firefox + PipeWire in VMs

As of today, update `api.alsa.headroom` to 8192 in `/usr/share/wireplumber/wireplumber.conf.d/alsa-vm.conf`.

Offline

Board footer

Powered by FluxBB