Pulseaudio freezes in pa_mainloop_poll causing mpv video player to freeze
Summary
When using the mpv video player to play any video, if the video is paused for more than approximately 5-10 seconds, when the video player is unpaused, the player freezes for more than a second. Additionally after unpausing there is some jerky playback from audio/video desync.
The issue started after a recent system upgrade after I hadn't updated in several months.
To be clear, when using straight ALSA none of these problems are experienced.
Some general system info:
- Arch Linux on a custom built Home Theater PC.
- System hooked to TV via HDMI cable to home theater system and then to TV. Audio is routed through HDMI.
- NVidia GTX 1660 Ti video card
- MSI B450I GAMING PLUS AC motherboard
environment
Output of pa-info script:
Annotated pulseaudio log from pulseaudio -vvvvv
from video player start to video player exit:
Steps to reproduce
After experiencing this I narrowed the cause down via strace to see what was syscall was hanging.
This was the hung syscall:
[pid 122173] poll([{fd=7, events=POLLIN}, {fd=10, events=POLLIN}, {fd=11, events=POLLIN}], 3, 3000
Via the pid I tracked it down to the thread in mpv that was causing it and the stack trace of that thread is below. This was the only thread that wasn't in pthread_cond_timedwait
or pthread_cond_wait
or waiting on keyboard input.
Stack trace:
#0 0x00007f0bd4ccc9ef in poll () from /usr/lib/libc.so.6
#1 0x00007f0bd55bbc14 in poll (__timeout=30000, __nfds=3, __fds=0x7f0ba00071c0) at /usr/include/bits/poll2.h:46
#2 poll_func (ufds=0x7f0ba00071c0, nfds=3, timeout=30000, userdata=0x556bf90ea150) at ../pulseaudio/src/pulse/thread-mainloop.c:70
#3 0x00007f0bd55c9059 in pa_mainloop_poll (m=m@entry=0x556bf90ecec0) at ../pulseaudio/src/pulse/mainloop.c:824
#4 0x00007f0bd55d3301 in pa_mainloop_iterate (m=m@entry=0x556bf90ecec0, block=block@entry=1, retval=retval@entry=0x0) at ../pulseaudio/src/pulse/mainloop.c:926
#5 0x00007f0bd55d33b1 in pa_mainloop_run (m=0x556bf90ecec0, retval=0x0) at ../pulseaudio/src/pulse/mainloop.c:945
#6 0x00007f0bd55c361e in thread (userdata=0x556bf90ea5b0) at ../pulseaudio/src/pulse/thread-mainloop.c:101
#7 0x00007f0bcf435d1c in internal_thread_func (userdata=0x556bf90eb210) at ../pulseaudio/src/pulsecore/thread-posix.c:81
#8 0x00007f0bd59d34cf in start_thread () from /usr/lib/libpthread.so.0
#9 0x00007f0bd4cd72d3 in clone () from /usr/lib/libc.so.6
What is the current bug behavior?
Mpv freezes upon unpause and pulseaudio freezes on a poll
What is the expected correct behavior?
Mpv shouldn't freeze upon unpause and pulseaudio shouldn't freeze on a poll