hrkfdn / ncspot

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash on playback, Termux, Aarch64

WyntrHeart opened this issue · comments

Describe the bug
Attempting to play any song instantly crashes ncspot without any error message.

To Reproduce

  1. Install ncspot by doing 'pkg install ncspot'
  2. Open ncspot
  3. Attempt to play any song

Expected behavior
The song should play

System (please complete the following information):

  • OS: Android 9
  • Terminal: Termux
  • Version: v0.13.4
  • Installed from: Termux

Backtrace/Debug log
"https://github.com/hrkfdn/ncspot#debugging" doesn't exist, and I don't know where to obtain the relevant logs. If someone tells me how to obtain these logs I will provide them.
I can't do a backtrace because this issue is with a release build.

Additional context
I tried to work around the problem by building from source, which is the only solution I found in similar issues, but using either "cargo install ncspot" or "cargo build --release" from a source directory just hangs indefinitely for me on the second to last step.

Use the -d/--debug option to enable debug logging to a file.
See ncspot --help or man ncspot for more.

I can't do a backtrace because this issue is with a release build.

It would probably be useful regardless of the build. The backtrace also includes the reason why the program crashed, even though the backtrace itself won't be that helpful. It should be automatically generated in the ncspot cache directory after a crash.

So I hadn't touched ncspot at all since my previous post, and I just tried to start it to get the debug logs as instructed, but now it doesn't even open the player. The login screen works, but once I login it crashes immediately. I did find the backtrace and got a debug log, but the debug log may not show whatever caused the original issue since this new issue has appeared.
ncspot-debug.log
backtrace.log

Ah, I think I already see from the backtrace. This is something I added about a month or so ago. It's some code to look for a runtime directory for runtime files (like the IPC socket) that probably can't find any suitable runtime directory on Android. It used the user cache directory before from what I remember, but that shouldn't be used for runtime files so it was instead moved to directories like /run/user/ or /tmp/. I don't know what the available directories are on Termux. I'll try to have a look and see what's going wrong.

EDIT: If I can't find a suitable runtime directory for Android, I'll create a PR soon to disable IPC until a better solution is found, if that's OK. Then at least it won't crash anymore.

there is a tmp directory at /data/data/com.termux/files/usr/tmp

I just disabled IPC on platforms with unknown user runtime directory for now which seems like the simplest fix. I'll let @hrkfdn decide what the best approach is in this case. I don't want one of my changes to completely bork Android support, but it's not a supported platform and there would have to be a contributor who is familiar with it and enough interest probably to properly support the platform (different directories, other differences...) I wonder whether Zellij works on Android and if so, what approach it uses since it also uses the user runtime directory. I looked at how Zellij did it when I added the feature here.

The crash should now be fixed on the main branch. The initial bug related to this issue is probably still there though. If you want you could share another debug log & backtrace for that :)

Crash fix worked (and it actually compiles on my phone now too, idk what was up with that)
backtrace.log
ncspot-debug.log

I hadn't actually checked the contents of the backtrace until just now, looks like its the same one from before. Is there something I can do to make it generate a new one?

Also some additional info I hadn't specified before: when this crash happens it breaks the whole terminal session and I have to close it with ctrl + D and open a new one

The Ctrl+D was probably because ncspot doesn't reset the terminal after a crash, which leaves it in a weird state making it unusable.

The last line in the log mentions an issue with the connection to PulseAudio. I don't know Android well enough to know what could cause this or whether PulseAudio is even installed/running in Termux. I don't know what could have changed in the newer versions that causes this crash. My guess would be that you could use a different audio backend like ALSA which wouldn't require PulseAudio to be installed/running.

[2024-01-06][18:05:57] [librespot_playback::player] [ERROR] Audio Sink Error Connection Refused: <PulseAudioSink> Connection refused

Termux does have PulseAudio, and does not have ALSA