poxu / runmpv

Runner, which allows to have only one mpv instance on Windows and Linux
6 stars 0 forks source link

Has a 5 second delay when loading videos yet "normal" mpv loads videos in half a second? #19

Closed NintendoManiac64 closed 2 years ago

NintendoManiac64 commented 2 years ago

I'm running all SSDs on my PCs and my current PC is even running an NVMe SSD. Opening a video in "normal" mpv takes all of something like half a second but, if I load the very same video through runmpv, the program window opens that says "drop files or URLs to play here" and it stays on that screen for 5 seconds before finally loading the video (that is also when the file name for the loaded video also appears).

I did find the option "waitSeconds=5" in the "runmpv.properties" file but it seems to make no difference for this issue regardless of whether I set the value smaller, larger, or even comment it out.

For reference, this issue occurs regardless of whether mpv was already open or not. I personally am running Linux Mint 20.3 XFCE at this time.

I'll be honest, this 5-second wait is much more annoying than having to deal with accidentally launching two instances of mpv because I can even close the second instance within that amount of time, not to mention it makes it particularly annoying for when you're just trying to quickly check multiple different videos in order to find a specific one.

poxu commented 2 years ago

Wow! Thank you for such a thorough description!

"waitSeconds=5" means, that runmpv waits 5 seconds for mpv to launch,and then quits if mpv couldn't start successfully. So, what you are describing shouldn't happen and is obviously a bug, that needs fixing.

I'll try repoducing it on my local machine. Or I'll install Linux Mint 20.3 in Virtual Box . Hope the bug is reproducible with a fresh install.

I might need your help though. Could you tell me, which version of mpv you're using, in case you've installed it from third party repository. What mpv --version prints? And I might ask you to send runmpv logs later, but I'll try my best to fix the issue without them.

Also, I clearly have no way of finding out, which version of runmpv you're using, which is totally my fault. I'll add an option to print runmpv version with --version flag, that will help diagnosing problems later.

NintendoManiac64 commented 2 years ago

mpv --version prints the following:

mpv 0.34.0-UNKNOWN Copyright © 2000-2022 mpv/MPlayer/mplayer2 projects
 built on Tue May  3 23:24:39 EDT 2022
FFmpeg library versions:
   libavutil       57.24.101
   libavcodec      59.27.100
   libavformat     59.23.100
   libswscale      6.6.100
   libavfilter     8.37.100
   libswresample   4.6.100
FFmpeg version: N-106797-g580fb6a8c9

For reference, I had compiled it myself the using the following instructions because, AFAICT, the following is basically the only way to get mpv + vapoursynth (there's a snap floating around that supposedly is mpv + vapoursynth but I couldn't ever get the snap to work, not to mention I'm one of those people that don't like snap and would prefer flatpak and Mint even disables snap support by default):

Note that, at least on Mint 20.1 (I've not felt daring enough to try without it on 20.3), you need the "libicu-le-hb-dev" package installed before following the above instructions or else the mpv+vapoursynth compilation step will fail.

(it may be worth noting that I myself am actually quite a Linux beginner as well as being very lacking in the software-dev department, though I seem to be quite proficient at bug reporting; regardless, I'm much more of a hardware person)

poxu commented 2 years ago

So, I was able to reproduce the issue with fresh Mint 20.3 install.

runmpv requires xdotool to focus mpv window, after a new video is loaded into existing mpv instance. And xdotool is not installed by default. To quickly test if you're experiencing the same problem, you can just open runmpv.properties and change focusAfterOpen=true to focusAfterOpen=false. Videos should open quickly after that.

If you don't want to focus mpv after opening files, you can leave config as is. If you want that functionality though, then you need to install xdotool .

In case you want more details, here they are. runmpv calls xdotool to focus mpv window. In case calling xdotool caused error, runmpv calls xdotool again and again for 4 seconds. That was needed, because after first launch runmpv was trying to focus mpv window, before the windows was registered by the system. Windows version of runmpv simply doesn't try focusing mpv window after first launch, because mpv itself does that. But linux version still works differently as because of that I didn't think to remove the code, which repeatedly called xdotool.

I guess the best way to fix the issue would be calling xdotool just once or twice. And also I need write warning to log file. I'll do that as soon as possible, probably today.

Thank you for noticing and describing the problem, I wouldn't know I had such an obvious issue if not for you! Still, I'd ask you to test your issue is the one I'm describing )))

NintendoManiac64 commented 2 years ago

Yep, that worked! I must say, with all of the bug reports I've made in the last few months, you're definitely one of if not the quickest to respond as well as the most in-depth with replying and investigating the issue.

Interestingly, even though I now have the focusAfterOpen=false setting set as such in my runmpv.properties file, the resulting mpv window actually seems to still be focused (e.g. pressing the space bar immediately after opening the video still pauses the video as expected).

Now if only the otherwise excellent xrandr.lua mpv script didn't break when dealing with custom refresh rates/resolutions, then I'd be able to fully replicate my setup that I had on Windows with MPC-HC as my monitor is "dumb" with a default EDID of only 60Hz at full resolution despite the monitor functioning without issue (e.g. no skipped frames) anywhere between 48Hz and 75Hz...

poxu commented 2 years ago

I'm glad I could help you!

I have made a fix. You can download it from release section. v2.2.4 .

As for still focusing even if focusAfterOpen=false - that's weird. In that case mpv should be focused only after you open the first file and create a new mpv instance. Are you sure mpv takes focus even if you have active mpv window and runmpv opens a new video in that existing mpv instance?

NintendoManiac64 commented 2 years ago

Oh, I misunderstood what the focusAfterOpen=false did. Yes, it is behaving exactly as you describe.

Nevertheless, simply installing xdotool through the package manager allowed the program window to remain focused without issue.