z411 / trackma

Open multi-site list manager for Unix-like systems. (ex-wMAL)
https://z411.github.io/trackma
GNU General Public License v3.0
778 stars 82 forks source link

Playing episodes stopped working #525

Open FichteFoll opened 3 years ago

FichteFoll commented 3 years ago

Some time ago (unfortunately I don't remember when exactly), playing a file stopped working without me modifying the config. I suspect it was an update, but I want to confirm the issue first.

Using trackma -d, the following is printed on the terminal, but nothing happens.

FichteFoll [anilist] (anime) watching >> play 2
Engine: Getting Adachi and Shimamura 4 from library...
Engine: Found. Starting player...
FichteFoll [anilist] (anime) watching >>

It also does not work with the gtk frontend. I'm using a build fresh off master and my player config is "mpv".

I will bisect later if you can't reproduce.

FichteFoll commented 3 years ago

I forgot to mention I was on Arch Linux.

Anyway, browsing my notifications, I spotted https://github.com/z411/trackma/pull/513, which may be related to my problem. I'll verify that later when I find the time.

z411 commented 3 years ago

Can reproduce. As an aside, the Qt interface hard locks up when trying to play an episode. Seems severe. Will look into this as well.

ahmubashshir commented 3 years ago

Gtk frontend is working, command line and curses are working too... launched player isn't being forked off in qt interface... I'm using my local branch.

ahmubashshir commented 3 years ago

After searching about QThread and os.fork I found out that they doesn't work well together. I'm working on it.

z411 commented 3 years ago

To fix this we need help in issue #508 to reproduce a bug. Anyone willing to test the prevent-zombie branch to see if closing Trackma also closes any player started by Trackma is welcome.

FichteFoll commented 3 years ago

I just tested prevent-zombie and play works and the player is closed when I ctrl-c in trackma but not when I ctrl+d.

FichteFoll commented 2 years ago

I was able to determine the cause by my player setting being set to simply mpv where the spawn code uses os.execv, which does not perform a PATH lookup. Changing my setting to /usr/bin/mpv makes the player process behave as expected in that it outlives trackma when it is closed but also does not come up in zps -l when killed before mpv. Monitoring the process tree with htop also reveals that the player process is parented to the init process.

I suggest to

  1. (optionally) wrap the player configuration with shutil.where
  2. check if the specified path exists and fail early
  3. determine if redirecting the std{in,out,err} file descriptors to /dev/null is necessary because at least mpv doesn't pollute the output of my trackma-cli when I remove the code for that, so that failures of os.exec* can be reported and debugged