Audio pops and clicks on Linux only

Hello,

I’m using Retroarch 1.22 on Fedora with pipewire and vulkan, and an NVidia GTX 1660 GPU. On all cores, I have audio pops, especially after the game starts for a few seconds, and then occasionally during gameplay. It’s not a speed issue because when I fast-forward a game I get ~3000 fps.

On Windows 10 the same games / cores run fine without pops.

I’ve tried the following :

  • Increasing / decreasing audio_max_timing_skew
  • Increasing / decreasing audio_rate_control_delta
  • Changing the audio driver to pulseaudio
  • Changing the video driver to gl.
  • Increasing audio latency from 64 ms to 256 ms

The only way to prevent these pops was to disable V-Sync, but then the framerate visibly drops to ~15 fps and looks irregular. As I understand it, disabling V-Sync may introduce some occasional tearing, but it should not cause such a framerate drop. When disabling V-Sync on Windows, the framerate stays smooth. It seems I have some serious sync issues on Linux. Maybe a driver problem ? The driver is set to always run on the maximum power state (P0), so it shouldn’t be a power management problem.

Thanks for any suggestions.

Are you using wayland or X? If the former, can you try the latter?

@Cutter Also, please provide some log and try to make a test with nightly build. Thank you.

I’m running Retroarch on Gnome + Wayland. I ran it on XFCE + X11 for comparison because Gnome only supports Wayland. Pops / clicks also happened on X11, maybe less often, it’s hard to tell. When they occur the dropped frame counter increases.

Here are the logs:

Log of Retroarch on X11 (Fedora XFCE)

retroarch.cfg (X11)

glxinfo:

$ glxinfo | grep -i nvidia
server glx vendor string: NVIDIA Corporation
client glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce GTX 1660/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 595.80
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 595.80
OpenGL shading language version string: 4.60 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 595.80

Log of Retroarch on Wayland (Fedora Gnome)

retroarch.cfg (Wayland)

glxinfo:

$ glxinfo | grep NVI
client glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce GTX 1660/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 595.80
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 595.80
OpenGL shading language version string: 4.60 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 595.80

Switching from the NVIDIA proprietary driver to the open source driver nouveau didn’t solve the audio pops.

Enabling threaded video replaces audio pops with framerate stutters.

It seems you don’t have default for ?

audio_max_timing_skew = "0.010000"
audio_rate_control_delta = "0.001000"

Can you try with the nightly which is an AppImage as you will get default settings (and it won’t interfere with your current installation)

curl -O https://buildbot.libretro.com/nightly/linux/x86_64/RetroArch.7z
7z x RetroArch.7z
cd RetroArch-Linux-x86_64
./RetroArch-Linux-x86_64.AppImage

Thank you.

I tried the nightly with default values for the two settings, audio pops / clicks still occurred.

Hey there,

You can check pops resulting from pipewire’s buffer underruns (ERR) with the command

pw-top

Pipewire use default latency values from its conf file, usually /etc/pipewire/pipewire.conf.

You can edit that file with gedit or another editor of your choice as super user.

sudo gedit /etc/pipewire/pipewire.conf

A while ago after changing card, I had issues with pops and crackles under load, not specific with retroarch tho, so I dont know if it could help you, but anyway, here we go… I edited the file to tweak the values of

default.clock.rate          = 48000
default.clock.allowed-rates = [ 48000  ]

default.clock.quantum       = 2048
default.clock.min-quantum   = 64
default.clock.max-quantum   = 4096

These are the samplerate and number of sample per buffer, which is variable per application in pipewire if I understood correctly. So not a value in ms, but quantum divided by clock rate will give you the latency in second. Depending on your soundcard driver you should be able to find a default sweet spot value so that the audio doesn’t pop under heavy CPU load. My default quantum value here for the intel onboard sound is 1024, I had to increase it from its default. Reducing the min-max fork values also helped. YMMV.

Effects only apply after a pipewire service restart.

Minimizing audio latency may require installing a real-time kernel at some point, going back to ALSA-Jack, but that’s another rabbit hole. GLHF!

Thanks. The pops are specific to Retroarch, I don’t get them with most programs. pw-top doesn’t show any errors for Retroarch when pops occur (the error counter stays at 0).

I’ve noticed that the pops occur more often when other applications are running besides Retroarch (for example, the Gnome Resources app). It looks like Retroarch is highly sensitive to other apps taking some CPU time, despite the fact that both process consume no more than ~1.5 % CPU.

I did some more testing and tried the following tweaks (mostly from this guide):

  • Added myself to group pipewire to fix a permission issue when audio processes requested realtime priority
  • Switched kernel preemption model from lazy to full
  • Disabled pipewire suspension
  • Disabled the pipewire real time canary
  • Added 44100 to allowed pipewire clock rates
  • Increased pipewire head room
  • Set head room to zero
  • Increased period size
  • Decreased period size
  • Increased default.clock.min-quantum
  • Decreased default.clock.max-quantum

None of those worked.

I also tested Retroarch on XFCE and KDE and found the same issues there. One exception was running Retroarch with the tinyalsa driver on KDE. Using tinyalsa reduced audio pops by ~90 %. pw-top didn’t list Retroarch as a running process when tinyalsa was the audio driver, so I assume the only way to play Retroarch with a mostly clean sound on my hardware is to bypass pipewire altogether.

Other audio applications using pipewire, including standalone emulators, do not produce audio pops.

Hey there,

Good to read TinyAlsa may solve your problem.

I’m just a user of Retroarch on linux like you, so I dont know if that could be of any help and have only a very limited understanding of pipewire and retroarch, but if you still tweak your install, maybe try

  • Disabling the microphone in retroarch, if active, from the same driver or any other board.
  • If not already, install feral interactive gamemode and set it to “on” in retroarch. In my understanding it will set the nice level of the app priority automatically and thus may improve how pipewire handles its audio.

Do you reproduce the issue without using crt-royale shaders ?

Thank you.

Good to read TinyAlsa may solve your problem.

I just tested it again and I didn’t see an improvement this time. I could not reproduce the conditions where TinyAlsa caused an improvement.

Disabling the microphone didn’t improve the situation.

I’m already using Feral Game Mode (it is installed and enabled) but somehow retroarch still runs with a niceness level of zero.

Disabling shaders didn’t improve the situation.

Maybe this is not an audio problem. Retroarch seems very sensitive to other programs eating some of its CPU time. Running a process monitor in the background causes audio pops, despite both programs not consuming more than 3% of CPU. Even with a low CPU-requirements core like SMS-Plus GX, frames keep being dropped randomly, even with the sound disabled.