smplayer-dev / smplayer

Free Media Player for Windows, Linux and Mac OS with YouTube support.
https://smplayer.info
GNU General Public License v2.0
685 stars 94 forks source link

Implementation of Wayland idle-inhibit and a few questions #998

Open Bluey26 opened 5 months ago

Bluey26 commented 5 months ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Hello, i started to use Wayland a few weeks ago and smplayer works overall really good in it, but i have one issue that has been mentioned in other bug tickets, but there's only a workaround for Gnome Wayland.

I would like to make smplayer to deactivate the screensaver features, just like mpv does in wayland now. For some reason, mpv is able to do it (but i cannot benefit from all smplayer advantages over mpv).

Describe the solution you'd like A clear and concise description of what you want to happen.

I could suggest to implement the idle-inhibit protocol from Wayland instead of only the "Gnome method" so wlroots users can also have it (i.e firefox seems to have both idle inhibitor methods).

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Other option would be to tell mpv to deactivate the screensaver, since smplayer launches a mpv instance under the hood, and mpv seems to successfully deactivate the screensaver (swayidle in my case).

Additional context Add any other context or screenshots about the feature request here.

I also wanted to ask the following: does the lastest version available in Archlinux packages (24.5.0) runs under native Wayland or there's still some things that do not work in native wayland? My WM appswitcher (labwc) tells me that smplayer is running under xwayland which seems to indicate a its a Xwayland and not a Wayland native app.

Regarding this, i have an issue with that because since wayland to xwayland copy/paste is currently not working in my WM, i have to use other Xwayland file-manager (forcing xwayland thunar, for example) to open subtitles by dropping them in smplayer (works properly in x11).

Another thing that i wold like to comment is that i have noticed some kind of "blurry" in the volume bars and text from the "OSD" options, which seems to be depending on the video quality because 1080p video dont show it that way, but it happens with 360p video. This does not seem to happen in X11 either, and i suspect there is also some kind of blurriness in the videos, so i wanted to also ask if there is something different regarding the decoding/muxing parameters in the current Xwayland SMplayer.

smplayer-dev commented 5 months ago

Could you test if the problem is still present in this build? https://github.com/smplayer-dev/smplayer/actions/runs/9645647826 (the artifact at the bottom)

Bluey26 commented 5 months ago

Could you test if the problem is still present in this build? https://github.com/smplayer-dev/smplayer/actions/runs/9645647826 (the artifact at the bottom)

Uhmm, unfortunately i still see the blurry OSD thing, i just also realized that this affects subtitles text too.

What i did for the testing was:

Cloning https://github.com/smplayer-dev/smplayer/tree/bed577abbd3f9d072558147625367a87d68d99bd

then i ran make inside the "master" folder.

This compiled the program successfully and made a binary in $SOURCEDIR/src called smplayer

Upon opening it and run a test video, the issue persist, so i decided to compile it using the gitlab archlinux repository ( https://gitlab.archlinux.org/archlinux/packaging/packages/smplayer ), since i think i saw a change in the archlinux build file (.github/workflows/build-archlinux.yml) but even in that case the issue persists.

To compile the new commit using makepkg i used:

source=("git+https://github.com/smplayer-dev/smplayer#commit=bed577a")

and a few changes in the build and prepare (just replacing ${pkgname}-${pkgver} for ${pkgname}) to make the script work.

Now i also have this question:

Install.txt says that "Generic compilation" is obsolete, but then i saw that i could compile with make , does this means that make is installing some components in the system? I ran just make not make install

PS: I just realized that there was an already compiled artifact in your link, its the first time i see that in github. I also tried to use that one(extracted and ran the smplayer binary) and the issue seems to persist. Installing the package did not changed it either.

PS2: If you were refering to the idle-inhibit issue, i just changed my idle time to 30 seconds and played a video in smplayer fullscreen (using the artifact you provided) and the screen goes black (both in fullscreen and in maximized window).

smplayer-dev commented 5 months ago

I meant the idle-inhibit issue. In this version smplayer just tells mpv to disable the screensaver, so I don't know why it doesn't work.

In my computer mpv fails to disable the screensaver even when it runs alone.

I haven't seen any blurred OSD in my computer.

Bluey26 commented 5 months ago

I meant the idle-inhibit issue. In this version smplayer just tells mpv to disable the screensaver, so I don't know why it doesn't work.

In my computer mpv fails to disable the screensaver even when it runs alone.

I haven't seen any blurred OSD in my computer.

mpv screenlock disabler seems to work in here (swayidle), i am using labwc which uses wlroots, maybe the wm is the key factor in here? I recall at one topic that you said you were using gnome, which does not use wlroots.

About the blurred OSD, its a minimal effect, it only appears in "low quality" videos, like 360p ones with low bitrates. For 1080p and 720p it shows properly in Wayland. In x11 the 3 cases(360p,720p,1080p) show properly without "blurring".

Update I wonder if this has something to do with smplayer running in Xwayland: i tried 2 things:

i added --stop-screensaver into Preferences>Advanced>MPlayer/mpv , and this did not anything(the task manager shows that the mpv command had 2 times --stop-screensaver , 1 from this commit and one from my addition).

I activated this option called "Run MPlayer/mpv in its own window" and i noticed that even though mpv was opened, the screen have gone black, so i am suspecting that this Xwayland thing could be involved(unable to pass a wayland argument via xwayland?)

Update2: Effectively, running mpv under xwayland does not deactivates the screensaver:

env -u WAYLAND_DISPLAY mpv something.mp4

This does not deactivates the screensaver, so this could be the underlying cause to smplayer not being able to do the same (because it runs under xwayland).

Update3: I tried to force smplayer into using pure wayland, using:

QT_QPA_PLATFORM=wayland smplayer something.mp4

Labwc effectively shows that smplayer is now under wayland (xdg-shell), but this does not prevent the screensaver to being disabled for audios(.mp3) or for videos. Since i tried to play a video and it was only reproducing audio, i decided to activate again the option "run mpv in a separated window" and this opened mpv, but with a xwayland tab(instead of xdg-shell) and the screen turns black because the screensaver is not deactivated.

Update4 Sorry for the repeated updates, i just was trying other things and i discovered that "Wayland Support" Disabled ( Preferences>General>Video) and "Run mpv in its own window" seems to show the video without OSD blurriness and also the screensaver is disabled, when i open smplayer with:

QT_QPA_PLATFORM=wayland smplayer something.mp4

mpv and smplayer windows are using xdg-shell now, so i also can drag my subtitles from Wayland apps.

Bluey26 commented 1 month ago

Hi, since this worked for me i was wondering how could i obtain the code .diff that made it work in my use case.

I realized that the master git branch does not have this commit (for some reason it does not work like this one) so i wanted to obtain a .diff patch to apply to git master branch in the future.

I tried to make a diff between https://github.com/smplayer-dev/smplayer/tree/bed577abbd3f9d072558147625367a87d68d99bd and the previous commit without code that may be related to the patch,which seems to be https://github.com/smplayer-dev/smplayer/commit/03585731d814b45149bd24a65f734839d870d696

downloaded the sources of both commits and i ran: git diff smplayer-03585731d814b45149bd24a65f734839d870d696 smplayer-bed577abbd3f9d072558147625367a87d68d99bd > diff.patch

then i tried to patch the git master branch using a prepare{} function that worked for me in the past, but it says:

==> Starting prepare()...
error: patch failed: src/core.cpp:49
error: src/core.cpp: patch does not apply
error: patch failed: src/core.h:33
error: src/core.h: patch does not apply
error: patch failed: src/smplayer.pro:594
error: src/smplayer.pro: patch does not apply

Looking at the code it seems that git master has the changes proposed but it does not work for some reason. bed577a still works in here (i even compiled it from source and worked too).

Maybe i am missing some detail, i am not too experimented with git.

The prepare function i am using is:

prepare() {
  cd "$srcdir/smplayer"
  git apply ../../parche.diff
  cd ${pkgname}
  # make build reproducible, we compress ourselves
  sed '/gzip -9/d' -i Makefile
}

I also append in here the patch (parche.diff) in case you want to try it. I find it strange that the master version does not work as the commit, could it be some kind of regression?

parche.diff.txt

PS: inside the patch, i had to replace a/smplayer-03585731d814b45149bd24a65f734839d870d696/ for a/src/ to make it work with the folder names in the master. The prepare function goes inside the PKGBUILD, i use this one as model: https://gitlab.archlinux.org/archlinux/packaging/packages/smplayer/-/blob/main/PKGBUILD?ref_type=heads , with source=("git+https://github.com/smplayer-dev/smplayer.git")

Thanks in advance.