Sound output managed by PulseAudio becomes fuzzy after playing audio in Firefox

Hi,
I find pulse audio delivers fuzzy audio after visiting some websites, in firefox, there is a complicated fix somewhere , however I wondered is it possible just to try to give it a slightly higher priority on startup just to see if that's a quick fix? This problem didn't seem to exist a year ago and now it happens regularly. Thanks in advance.

I had issues with an ARM based Raspberry Pi 4 and there were some online instructions available that fixed it. But I’ve never had any problems with a new PC or laptop. What kind of device are you using?

lshw
WARNING: you should run this program as super-user.
home
description: Computer
width: 64 bits
capabilities: smp vsyscall32
*-core
description: Motherboard
physical id: 0
*-memory
description: System memory
physical id: 0
size: 10GiB
*-cpu
product: AMD FX(tm)-8350 Eight-Core Processor
vendor: Advanced Micro Devices [AMD]
physical id: 1
bus info: cpu@0
size: 1404MHz
capacity: 4GHz
width: 64 bits

       *-multimedia
            description: Audio device
            product: Oland/Hainan/Cape Verde/Pitcairn HDMI Audio [Radeon HD 7000 Series]
            vendor: Advanced Micro Devices, Inc. [AMD/ATI]
            physical id: 0.1
            bus info: pci@0000:01:00.1
            version: 00
            width: 64 bits
            clock: 33MHz
            capabilities: bus_master cap_list
            configuration: driver=snd_hda_intel latency=0
            resources: irq:37 memory:fea9c000-fea9ffff
    *-multimedia
         description: Audio device
         product: SBx00 Azalia (Intel HDA)
         vendor: Advanced Micro Devices, Inc. [AMD/ATI]
         physical id: 14.2
         bus info: pci@0000:00:14.2
         version: 00
         width: 64 bits
         clock: 33MHz
         capabilities: bus_master cap_list
         configuration: driver=snd_hda_intel latency=64
         resources: irq:16 memory:fe9f4000-fe9f7fff

To described it better, the fuzziness is like some kind of echo, its where you can here someone say something on a video playing and then you hear it about a half a second later, so its like you hear a mix of two timelines of it and its not clear, its fuzzy. Bit like static.

Today it happened just upon opening sky news whilst playing an mp3 in VLC.

If nobody knows an answer to this , that's fine, however if you know if its possible to start the pulse audio service with high than usual privileges just to see if it helps, can you please advise so? Thanks in advance.

Pulse already runs default with a much higher priority than everything else.
The echo that you hear is possibly firefox corrupting the soundbuffer.

Try another browser , brave-browser for instance, and see if it also corrupts the sound.
If it doesn't it would be a great idea to report a bug at mozilla.

b.t.w., I never encountered this problem. Not on my machines nor anyone else's
so I'm afraid I'm out of ideas on this one at the moment.

Well today I have noticed the echo only happens after I open firefox and then start moving the scroll bar to go up and down the page, I tested this several times. It seems when I close firefox the echo problem disappears several seconds later. When I raised the priority of pule audio, this stopped happening. Is there a way to raise the priority of pulse audio by default?

Try to edit the unitfile that autostarts pulseaudio:
/etc/systemd/user/default.target.wants/pulseaudio.service
change this part:

[Service]
ExecStart=/usr/bin/pulseaudio --daemonize=no --log-target=journal
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes

to this:

[Service]
ExecStart=/usr/bin/pulseaudio --realtime=yes --daemonize=no --log-target=journal
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes

or this:

[Service]
ExecStart=/usr/bin/pulseaudio --high-priority=yes --daemonize=no --log-target=journal
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes

and see if it works.

Thank you very much for this, I will put it in the diary to report back on its success.

OK well, after a reboot, I do not know if it actually set it to high priority as the system doesn't show its current status when you look at it on the task manager,however the sound problem was repeated after I loaded up sky news whilst watching a video on amazon, I Will try realtime next.

OK well I just tried the realtime one and it still happened, however, I noticed when I closed firefox and reopened it the problem disappeared, so perhaps its within firefox itself. Is there anything else I can try?

Seems weird that stopping and starting pulse audio directly solves the problem and stopping and starting firefox also resolves the problem. Does it not?

What you should do now:

First try a different browser (preferrably brave) and see if it has the same problem.
If it has the same problem: file a bug against pulseaudio
If it works flawlessly: file a bug against firefox

If you want to attack the problem yourself there are few options:

You said earlier that you couldn't see the priority or niceness of the pulsaudio process so let's look at that first because if you're going to experiment it is highly recommmended that you can check the priority and niceness constantly. By default the process manager doesn't show these columns so you have to enable them in the settings.
(personally I prefer to use 'htop' for that, also because it works better)

Now you can check if '--high-priority=yes' did work.

If it didn't, this should work:

sudo renice -n -19 pulseaudio

If this is the only way for you to boost the priority, then it would involve a bit of reasonably complex scripting (with IPC) to automate this at logintime.

Perhaps it would be better to lower the priority of firefox instead of raise the priority of pulse.
It would also make any remidies a lot simpeler....can you try this first ??

The other way is to let pulse restart automatically a few seconds after you start firefox.

If this all doesn't work, you could configure pulseaudio to start systemwide instead of as a user instance. It will get the UID of the system and therefore a higher privilege and the possibility to easily elevate the priority. It is not for the faint of heart and you are completely on your own if you try this (and it might break with an update) but as a last resort it could be the solution for you. At least know that pulseaudio is designed to be able to run both systemwide or as a user instance, depending on your preference.

About the strange behaviour( like restarting pulse or firefox to temporary solve the problem):
Since you have an FX processor you have 8 integer cores and 4 floating point cores, which is very roughly comparable but still a completely different beast than 4 hyperthreaded or 8 non-hyperthreaded cores and can sometimes in very special and obscure cases behave also a little bit different than planned.
If you (temporarily) disable every odd core and the problem disappears then you know it's an architectural problem.

Still you must file a bug because although you have an FX-processor, the behaviour is still unacceptable :slight_smile:

1 Like

An update.

Since upgrading tot he latest Ubuntu a few weeks ago I have not experienced the sound issue. I was not aware you would need to upgrade the entire system and not just the various components...

1 Like