termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
12.77k stars 2.94k forks source link

[Bug]: PulseAudio hangs after a random amount of time #19861

Open tildearrow opened 2 months ago

tildearrow commented 2 months ago

Problem description

PulseAudio stops working completely after a random amount of time has elapsed. Sometimes it is as soon as a PulseAudio application starts, sometimes one second, sometimes five, and sometimes it works flawlessly. Sometimes putting Termux into background will trigger this issue, sometimes not.

Whenever it stops working, audio output stops and all PulseAudio-using applications become unresponsive. Even pactl fails and times out.

A workaround involves killing the PulseAudio process (with -KILL because neither TERM or INT seem to be able to kill it), but then there is a 10% chance that this issue will reappear.

Happens exclusively on Termux.

What steps will reproduce the bug?

  1. Run any PulseAudio-using application.
  2. Wait.

What is the expected behavior?

PulseAudio works and doesn't stop randomly.

System information

termux-info:

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=15459
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://grimler.se/termux/termux-main stable main
# x11-repo (sources.list.d/x11.list)
deb https://grimler.se/termux/termux-x11 x11 main
Updatable packages:
All packages up to date
termux-tools version:
1.42.0
Android version:
8.0.0
Kernel build information:
Linux localhost 4.9.65-13087568 #1 SMP PREEMPT Sun Feb 25 19:02:40 KST 2018 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-G9600
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
com.termux.x11 versionCode:9
com.termux.boot versionCode:7

PulseAudio package version: 17.0-1

PulseAudio configuration is the default one.

Biswa96 commented 2 months ago

Any kind of error output or log from strace or logcat would be helpful to debug the issue.

Yellow-Subroutine commented 2 months ago

I see the same behaviour, also with pulseaudio 17.0-1.

What happens is that the pulseaudio process becomes unresponsive and neither "pulseaudio -k" nor a kill terminate the process. The only way to get rid of it is via "kill -9".

I have run pulseaudio via strace and these are the last messages that appear for such an unresponsive process:

````read(3, "WWWWWW", 10)                   = 6      
read(3, 0x7fea298f9c, 10)               = -1 EAGAIN (Try again)                                       
ppoll([{fd=3, events=POLLIN}, {fd=24, events=POLLIN}, {fd=8, events=POLLIN}, {fd=15, events=POLLIN}, {fd=18, events=POLLIN}, {fd=9, events=POLLIN}, {fd=6, events=POLLIN}], 7, {tv_sec=4, tv_nsec=999049000}, NULL, 8) = 0 (Timeout)                 
write(16, "\1\0\0\0\0\0\0\0", 8)        = 8      
futex(0xb400007d4e405450, FUTEX_WAIT_BITSET_PRIVATE, 4294967294, NULL, FUTEX_BITSET_MATCH_ANY

This is probably not very helpful, please let me know how to produce a more helpful log...

tildearrow commented 2 months ago

I've been trying to strace PulseAudio all this time, but when I do, PulseAudio always works correctly (regardless of whether I do by attaching to the PulseAudio process or launching PulseAudio via strace). It only fails when I don't strace it, and only 20% of the time.

Neo-Oli commented 2 weeks ago

This happens for me too, but reproducible. It happens when a bluetooth device connects or disconnects. So it seems it happens when android changes the audio device the sinks are attached to. It also only seems to happen if the aaudio sink is loade, but I am not 100% sure about that.

ppoll([{fd=3, events=POLLIN}, {fd=10, events=POLLIN}, {fd=13, events=POLLIN}, {fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=7, e│
vents=POLLIN|POLLERR|POLLHUP}, {fd=7, events=0}, {fd=14, events=POLLIN}, {fd=17, events=POLLIN}, {fd=9, events=POLLIN}, {fd=8, events=│
POLLIN}, {fd=5, events=POLLIN}], 12, {tv_sec=3, tv_nsec=156478000}, NULL, 8) = 1 ([{fd=10, revents=POLLIN}], left {tv_sec=3, tv_nsec=1│
56473833})                                                                                                                            │
write(4, "W", 1)                        = 1                                                                                           │
recvmsg(10, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="L\0\0\09L\0\0\0\34L\0\0\0\0Tf\202\177\232\0\5\243\353", iov_len=24}], m│
sg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, cmsg_data={pid=20305, uid=10188, gid=10188}}│
], msg_controllen=32, msg_flags=0}, 0) = 24                                                                                           │
write(4, "W", 1)                        = 1                                                                                           │
futex(0xb400007046ff5590, FUTEX_WAIT_BITSET_PRIVATE, 4294967294, NULL, FUTEX_BITSET_MATCH_ANY