anufrievroman / waypaper

GUI wallpaper manager for Wayland and Xorg Linux systems
https://anufrievroman.gitbook.io/waypaper
GNU General Public License v3.0
396 stars 27 forks source link

High memory consumption with mpvpaper #97

Open cr1ogen opened 1 week ago

cr1ogen commented 1 week ago

When I use Waypaper with mpvpaper, there is a high memory consumption with ffmpeg

241111_18-50-39

and with mpvpaper that when changing the wallpaper, the first wallpaper remains running in the background.

241111_18-52-53

anufrievroman commented 1 week ago

@CalfMoon would you take a look at this? I'm not very familiar with mpvpaper, but it definitely shouldn't keep running previous wallpapers.

CalfMoon commented 1 week ago

In my computer ramusage never exceeded 400mb. which is also high but it might be because mpvpaper runs mpv in the background. Maybe 700mb is a resolution thing? how big is your monitor? And multiple process only seemed to form when the pictures are clicked multiple times rapidly which i think is because the previous process don't get enough time to get killed. The problem seemed to slightly decrease when the value of time.sleep() was increased. Maybe that is the problem. And I don't really know what ffmpeg is doing there. Im not really super proficient in python, and right now I don't have much free time so I'm sorry but someone else will have to take a closer look at it.

cr1ogen commented 1 week ago

Yes, I have a 4k monitor and I have no problems with the 700mb size. I was trying standalone mpvpaper and I don't get any ffmpeg logs in Bpytop like when I use it with Waypaper. I also tried changing the wallpaper with a time difference and the old one keeps working below the new one.

anufrievroman commented 1 week ago

It might be related to the thumbnail generation process, which should be over once you see the previews of the videos, but who knows. Could you try to click Refresh in the UI and see if that causes even more usage?

anufrievroman commented 1 week ago

@CalfMoon okay, I'll take a closer look before publishing it officially. But one small question, when you wrote:

subprocess.Popen(["killall", ".mpvpaper-wrapp"])

why is it ".mpvpaper-wrapp" and not just "mpvpaper" ?

cr1ogen commented 1 week ago

It might be related to the thumbnail generation process, which should be over once you see the previews of the videos, but who knows. Could you try to click Refresh in the UI and see if that causes even more usage?

I clicked Refresh in the UI and it doesn't cause any more use

anufrievroman commented 1 week ago

I clicked Refresh in the UI and it doesn't cause any more use

Okay, that's a good news. Thank you

anufrievroman commented 1 week ago

I also can confirm that previous processes are not killed because:

.mpvpaper-wrapp: no process found
cr1ogen commented 1 week ago

I clicked Refresh in the UI and it doesn't cause any more use

Okay, that's a good news. Thank you

Thank you for this great work

CalfMoon commented 1 week ago

I decided to use .mpvpaper-wrapp because the opposite happened in my computer, it detected .mpvpaper-wrapp but but not mpvpaper. I have no idea why it would be different for different systems.

anufrievroman commented 1 week ago

@cr1ogen hi, I reimplemented launching things in mpvpaper, if you have time, please test the current main branch, thanks

cr1ogen commented 1 week ago

@cr1ogen hi, I reimplemented launching things in mpvpaper, if you have time, please test the current main branch, thanks

Hello, the mpvpaper stop button works, but now in order to change the background, I have to stop mpvpaper otherwise it does not change the background

anufrievroman commented 1 week ago

Does this happen for you all the time? I mean, I know there are certain situation, for example, when you set one monitor, and then All, and and then you try to set first monitor again, but it is now behind the running mpvprocess for all monitors (so it changes but it's not visible). So, you must stop (kill) all processes with Stop, and then start from the fresh layer stack. But if you only change it just for one monitor with All, it is supposed to work without Stopping.

cr1ogen commented 6 days ago

Does this happen for you all the time? I mean, I know there are certain situation, for example, when you set one monitor, and then All, and and then you try to set first monitor again, but it is now behind the running mpvprocess for all monitors (so it changes but it's not visible). So, you must stop (kill) all processes with Stop, and then start from the fresh layer stack. But if you only change it just for one monitor with All, it is supposed to work without Stopping.

Yes, I only have one monitor

anufrievroman commented 6 days ago

I see, this is strange. Okay, I just released the version 2.4, if you have time, could you uninstall all previous versions and try with this new version? If the problem persists, a few questions:

anufrievroman commented 6 days ago

By the way, I could also reproduce very high CPU and memory consumption when I try to play 4k videos, but that's unfortunately how mpv plays it, nothing we can do here. For smaller videos, it's more reasonable.

cr1ogen commented 5 days ago

I see, this is strange. Okay, I just released the version 2.4, if you have time, could you uninstall all previous versions and try with this new version? If the problem persists, a few questions:

* What is you distribution and window manager?

* Does the original issue with high memory consumption still exist?

* Could you check your `/tmp/` folder and tell if there are files called mpv-socket-... ? (try to delete them and restart the program).

I use Debian, mpvpaper from git and use qtile The original issue still persistis i have mpv-socket and when i delete, when starting program is created again

cr1ogen commented 5 days ago

By the way, I could also reproduce very high CPU and memory consumption when I try to play 4k videos, but that's unfortunately how mpv plays it, nothing we can do here. For smaller videos, it's more reasonable.

ok, no problem

anufrievroman commented 5 days ago

I use Debian, mpvpaper from git and use qtile

But that's with Wayland, right?

So, now, beside the high resource consumption (which seems normal with mpv), the main problem that you can't just switch to the new video, you must Stop if first (essentially kill the mpvpaper process) and then choose a new one? One possible reason might be that you need socat to be installed. I thought it's everywhere by default, but please check if it's there...

cr1ogen commented 5 days ago

I use Debian, mpvpaper from git and use qtile

But that's with Wayland, right?

So, now, beside the high resource consumption (which seems normal with mpv), the main problem that you can't just switch to the new video, you must Stop if first (essentially kill the mpvpaper process) and then choose a new one? One possible reason might be that you need socat to be installed. I thought it's everywhere by default, but please check if it's there...

Yes it is Wayland, I installed socat which was not installed in Debian and now I can change wallpaper without stopping mpvpaper. Now, the high memory consumption is not due to the wallpaper, it is due to a ffmpeg process that appears when changing the background, which I don't know why it appears and if I use mpvpaper by itself, it doesn't

anufrievroman commented 5 days ago

Good, at least that problem is fixed.

The ffmpeg is used in waypaper only to cache images (at least explicitly), so once you see the thumbnails, there should be no ffmpeg process left. I'll try to reproduce it...

anufrievroman commented 2 days ago

To be honest, I couldn't really see any ffmpeg processes in my system, so it's very hard for me to say what might be wrong. If you have time, maybe you can try to see if, for example: 1) ffmpeg processes multiply when you change the video wallpaper? 2) Do they appear if you set a static image wallpaper with mpvpaper backend? 3) Perhaps there are some details about these processes, like, what is the full argument that is partly hiddedn in the screenshot above? 4) Do they appear for any kind of video? 5) Do they appear for specific fill types? (maybe they are needed to cut the video for the monitor ratio?)

cr1ogen commented 6 hours ago

To be honest, I couldn't really see any ffmpeg processes in my system, so it's very hard for me to say what might be wrong. If you have time, maybe you can try to see if, for example:

1. ffmpeg processes multiply when you change the video wallpaper?

2. Do they appear if you set a static image wallpaper with mpvpaper backend?

3. Perhaps there are some details about these processes, like, what is the full argument that is partly hiddedn in the screenshot above?

4. Do they appear for any kind of video?

5. Do they appear for specific fill types? (maybe they are needed to cut the video for the monitor ratio?)
  1. Yes
  2. No
  3. ffmpeg -nostdin -loglevel error -i /tmp/magik-FVzaZqvY_WsWRdoUW_oZsstAxUEG7rEv -an -f rawvodep -y -vcodec webp -lossless 1 /tmp/magik-dR_FNwppbAePoJAutSYGQF_RE9Bm2Wjd
  4. I tried with mp4, mkv and webm and it only doesn't work with webm
  5. appears in all fillings