Aanok / jftui

Jellyfin Terminal User Interface
The Unlicense
142 stars 7 forks source link

Segfault with mpv-mpris plugin #7

Closed Midek closed 4 years ago

Midek commented 4 years ago

With mpv-mpris plugin enabled, jftui will segfault after video finishes playing or when stopping playback with 'q'

jftui --version
0.2.2

Stack trace looks like this for both cases:

Thread 65 "mpv/SO plugin (" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe887e700 (LWP 357610)]
0x00007ffff7fc8ce5 in ?? () from /home/midek/.config/jftui/scripts/mpris.so
(gdb) bt
#0  0x00007ffff7fc8ce5 in  () at /home/midek/.config/jftui/scripts/mpris.so
#1  0x00007fffef28626f in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#2  0x00007fffef2881b1 in  () at /usr/lib/libglib-2.0.so.0
#3  0x00007fffef2890c3 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#4  0x00007ffff7fc9e7a in mpv_open_cplugin ()
    at /home/midek/.config/jftui/scripts/mpris.so
#5  0x00007ffff7b9b243 in  () at /usr/lib/libmpv.so.1
#6  0x00007ffff7b9b0eb in  () at /usr/lib/libmpv.so.1
#7  0x00007ffff7aba4cf in start_thread () at /usr/lib/libpthread.so.0
#8  0x00007ffff79e92d3 in clone () at /usr/lib/libc.so.6

Back on 0.2.1 version when video would stop playing on its own, jftui did not crash. As far as i remember, it did segfault when stopping mpv playback with 'q' though (i rarely stopped playback like this so it was not an issue)

PS. the mpv-mpris plugin version is 0.4-1, installed from AUR

Aanok commented 4 years ago

After some poking around, it seems mpv-mpris is using GLib in a way that doesn't work when you try to load the plugin again after the first time. This is bad for jftui, as there are no other ways to react to an MPV_EVENT_SHUTDOWN than restarting mpv from scratch or exiting. Shutdown events are spawned when mpv receives a quit command (like pressing q with the default bindings) so for the sake of uniformity (as a restart means losing property changes you made in the meantime, like the volume level), with the last release I made mpv restart also when jftui stops playback at the end of a playlist.

I'll try opening an issue with the dev, but I think it would be a lot of work to make mpv-mpris behave as we need it so I don't know if and when they might get to it.

Midek commented 4 years ago

If its not too much trouble, could you add configuration parameter that would restore old behavior and not send shutdown event when stopping playback?

Aanok commented 4 years ago

I'd rather not to be honest, the new behavior makes more sense outside of this issue. Frankly, I hadn't even realized jftui was trying to load scripts together with config files; they should be considered unsupported for now.

You may have another workaround, though: a stop command will not cause the mpv core to abort and need to be restarted, so you may want to remap your q key to that and manually kill playback before it's over. stop also makes normal mpv exit like quit so it's fine outside of jftui too.

Midek commented 4 years ago

I see, the new behavior indeed makes more sense. I guess i will just stay on the old version for the time being, and hope they fix the plugin.

Sorry to bother you with this, cheers.

Aanok commented 4 years ago

@Midek , FYI the problem was just kindly fixed on mpv-mpris's side, so if you rebuild it and install from the latest master (it's not in a release yet) it will play along nicely with jftui :)

Midek commented 4 years ago

Awesome, thanks!