Firefox audio issues: fails to play audio after a while

Hi, I’m having issues playing audio in Firefox. When the system starts, everything is fine, but after a while using Firefox (a day or two), the following error appears in the logs and Firefox cannot play audio anymore. I have to restart it to be able to play audio again:

2022-06-27T18:42:49.170668-05:00 polaris krunner[736684]: [Child 736684, AudioIPC0] WARNING: 7fd4d9a36dc0 StateCallback() state 0 cubeb error: file /builddir/build/BUILD/firefox-101.0.1/dom/media/AudioStream.cpp:658
2022-06-27T18:42:49.171040-05:00 polaris krunner[736684]: [Child 736684, MediaDecoderStateMachine #1] WARNING: 7fd4d9a36dc0 OpenCubeb() failed to init cubeb: file /builddir/build/BUILD/firefox-101.0.1/dom/media/AudioStream.cpp:277
2022-06-27T18:42:49.171040-05:00 polaris krunner[736684]: [Child 736684, MediaDecoderStateMachine #1] WARNING: Decoder=7fd4d6f08e00 [OnMediaSinkAudioError]: file /builddir/build/BUILD/firefox-101.0.1/dom/media/MediaDecoderStateMachine.cpp:4037
2022-06-27T18:42:49.171040-05:00 polaris krunner[736684]: [Child 736684, MediaDecoderStateMachine #1] WARNING: Decoder=7fd4d6f08e00 Decode error: NS_ERROR_DOM_MEDIA_MEDIASINK_ERR (0x806e000b) - OnMediaSinkAudioError: file /builddir/build/BUILD/firefox-101.0.1/dom/media/MediaDecoderStateMachine.cpp:3587

When this happens, Firefox starts to freeze when I visit sites that play video and audio, like twitter. It freezes for a moment and then recovers, but it can no longer play the video or audio.

What’s the best way to debug what’s the issue here?
Other applications can play audio fine. It looks like it’s something that happens after the application is running for a long time, as I typically have my PC running 24/7 for a week or so before shutting it down or restarting it. During that time, Firefox is open the whole time.

My system information:
Operating System: Fedora Linux 35
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.2
Kernel Version: 5.18.5-100.fc35.x86_64 (64-bit)
Graphics Platform: X11
Processors: 32 × AMD Ryzen 9 5950X 16-Core Processor
Memory: 62.7 GiB of RAM
Graphics Processor: AMD DIMGREY_CAVEFISH (AMD Radeon RX 6600 EAGLE 8G).

Do you keep firefox running constantly or do you close the browser and reopen it frequently? Sometimes the issues are with updates that cause mismatched software if the browser is not restarted. Sometimes it is memory problems. Sometimes it is a result of updated firmware.

All in all, you should restart your browser whenever you see this occur, and if that does not work then try rebooting the system.

I keep it open the whole time. During this time, I don’t perform system updates. Digging a bit more into the logs, it looks like some audio-related programs had issues opening files, because the default limit of 1024 was reached (the ulimit one). I increased this for my session to 16384, and I’m currently waiting to see if this problem pops up again. Maybe this is because of me having tons of tabs open playing videos and audio from Twitter, Instagram and TikTok, as well as Spotify web.

IIRC there have been several posts related to firefox and having lots of tabs open with both audio and other issues. It seems firefox becomes a memory hog at times and that may have some impact.