Freeze in Firefox/Thunderbird related to pipewire-pulse + libcanberra-pulse
For some time, I have random freezes when trying to opening menus in Firefox or Thunderbird. The application unfreezes after some long timeout. It apparently started to happening after I replaces PulseAudio with Pipewire.
The freeze happen because Firefox appanretly triggers a libcanberra notifification when opening a menu. This calls libcanberra-pulse (when this plugin is installed) which tries to initialize a pulseaudio main loop: this moon loop apparently never initialized correctly for some reason. It seems be be related to some state in pipewire-pulse because killing this process unfreezes the application.
All versions of Thunderbird/Firefox seems to be affected.
This is not reliably reproducible, it only happens from time to time. once it starts happening, restarting the application does not fix the problem and all the affected applications are affected at the same time.
What does not fix the issue:
- restarting the application.
What fixes the issue:
- restarting the system;
- killing wireplumber;
- killing and restarting wireplumber;
- killing pipewire-pulse;
- killing pipewire-pulse and restarting pipewire-pulse.
Killing wireplumber does not appear to unfreeze the frozen application but killing pipewire-pulse seems to unfreeze the frozen application.
I collected some stack traces and apparently the problem happens in libcanberra-pulse :
Thread 1 (Thread 0x7f5fdf4bb780 (LWP 2004) "firefox-bin"): #0 __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x7f5f992d5f3c) at ./nptl/futex-internal.c:57 #1 __futex_abstimed_wait_common (futex_word=futex_word@entry=0x7f5f992d5f3c, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0, cancel=cancel@entry=true) at ./nptl/futex-internal.c:87 #2 0x00007f5fdee844bb in __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x7f5f992d5f3c, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0) at ./nptl/futex-internal.c:139 #3 0x00007f5fdee86c00 in __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7f5f97b907c0, cond=0x7f5f992d5f10) at ./nptl/pthread_cond_wait.c:503 #4 ___pthread_cond_wait (cond=0x7f5f992d5f10, mutex=0x7f5f97b907c0) at ./nptl/pthread_cond_wait.c:618 #5 0x00007f5facf68577 in pa_cond_wait (c=, m=) at ../src/pulsecore/mutex-posix.c:146 #6 0x00007f5fad53da48 in pa_threaded_mainloop_wait (m=0x7f5f98c52f40) at ../src/pulse/thread-mainloop.c:216 #7 0x00007f5fae589d90 in pulse_driver_open (c=0x7f5fa5487440) at ./src/pulse.c:436 #8 0x00007f5f94f4e379 in driver_open (c=c@entry=0x7f5fa5487440) at ./src/dso.c:273 #9 0x00007f5f94f45868 in context_open_unlocked (c=c@entry=0x7f5fa5487440) at ./src/common.c:293 #10 0x00007f5f94f4650e in ca_context_play_full (c=c@entry=0x7f5fa5487440, id=id@entry=0, p=0x7f5f991c7de0, cb=cb@entry=0x0, userdata=userdata@entry=0x0) at ./src/common.c:517 #11 0x00007f5f94f46915 in ca_context_play (c=0x7f5fa5487440, id=0) at ./src/common.c:462 #12 0x00007f5fd520603c in nsSound::PlayEventSound(unsigned int) () from /home/gabriel/software/firefox/libxul.so #13 0x00007f5fd53f19cc in nsMenuPopupFrame::ShowPopup(bool) () from /home/gabriel/software/firefox/libxul.so #14 0x00007f5fd53fd8fb in nsXULPopupManager::ShowPopupCallback(nsIContent*, nsMenuPopupFrame*, bool, bool) () from /home/gabriel/software/firefox/libxul.so #15 0x00007f5fd53fc7a1 in nsXULPopupManager::BeginShowingPopup(PendingPopup const&, bool, bool) () from /home/gabriel/software/firefox/libxul.so #16 0x00007f5fd53fc485 in nsXULPopupManager::ShowMenu(nsIContent*, bool) () from /home/gabriel/software/firefox/libxul.so #17 0x00007f5fd53f9d60 in mozilla::detail::RunnableFunction::Run() () from /home/gabriel/software/firefox/libxul.so #18 0x00007f5fd7243f80 in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock const&) () from /home/gabriel/software/firefox/libxul.so #19 0x00007f5fd724b2ea in nsThread::ProcessNextEvent(bool, bool*) () from /home/gabriel/software/firefox/libxul.so #20 0x00007f5fd72928f5 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) () from /home/gabriel/software/firefox/libxul.so #21 0x00007f5fd7dd032f in MessageLoop::Run() () from /home/gabriel/software/firefox/libxul.so #22 0x00007f5fd84f4249 in nsBaseAppShell::Run() () from /home/gabriel/software/firefox/libxul.so #23 0x00007f5fd5fc75c5 in nsAppStartup::Run() () from /home/gabriel/software/firefox/libxul.so #24 0x00007f5fd603cf60 in XREMain::XRE_mainRun() () from /home/gabriel/software/firefox/libxul.so #25 0x00007f5fd603d893 in XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) () from /home/gabriel/software/firefox/libxul.so #26 0x00007f5fd603dc76 in XRE_main(int, char**, mozilla::BootstrapConfig const&) () from /home/gabriel/software/firefox/libxul.so #27 0x000055b10856e652 in main () [Inferior 1 (process 2004) detached]
Apparently clicking on a menu triggers a libcanberra notification which goes trough pulseaudio (through libcanberra-pulse). Looking at canberra source code, it creates a pulse audio threaded mainloop which appears to never reach the PA_CONTEXT_READY state.
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1012563