Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Optionally Cache Static Images in Memory #175

Open
tyush opened this issue Oct 2, 2023 · 3 comments
Open

Feature Request: Optionally Cache Static Images in Memory #175

tyush opened this issue Oct 2, 2023 · 3 comments

Comments

@tyush
Copy link

tyush commented Oct 2, 2023

Hello,

I'm using swww for my desktop. I have a script that rapidly (anywhere from 1 to 8 times a second) asks the daemon to change the wallpaper between 3 images at varying speeds.

However, swww takes significant power trying to re-read the entire image from disk every swap even when they haven't changed.

Proposed Feature

Add two flags to the swww img command: --cache and --update-cache.

Wallpapers loaded using the --cache flag have the image read from a cache in memory, only reading from the file system if the image is not in the cache. Using the --update-cache option forces the image to be read from the file system, updating the image or adding it to the cache.

No change is made to program behavior not involving these flags. swww itself does not track files for changes.

@LGFae
Copy link
Owner

LGFae commented Dec 21, 2023

Ah, sorry, this sounds way too complicated. I know that at a high level it seems simple, but we would have to change a lot of things to implement it. For example, we couldn't just cache their bytes, we would also need to keep, at a minimum, their width, height and filename, since we can only use them if all of those match. Things can get annoying with multiple monitors configurations, at varying scale factors, etc.

Also, more importantly, I am trying to get memory usage down, not up. This would go completely against that.

To get what you want, may I suggest creating a gif with those 3 images? You can control their framerate during their creation. ffmpeg can be used for it.

To get something a little randomized (if that's what you want) your script can try recreating the gif every once in a while with different random framerates.

@Aurillium
Copy link

My use case for this is that I have a different wallpaper for each workspace and want to speed up the transition between wallpapers (right now it's quite slow) when I change workspaces.
To prevent most people's RAM usage being increased the feature could only be enabled when a certain option is passed to the daemon and only added to with a --cache argument to swww img?

If I have enough spare time (not likely for a while) I'm happy to try implement this myself and submit a PR.
If you don't want that though do you have any recommendations on how to solve the issue without modification? I've tried copying the files to a RAM filesystem on load but I haven't noticed any difference

@LGFae
Copy link
Owner

LGFae commented Apr 18, 2024

I am thinking of maybe implementing this using temporary files. That way, we wouldn't be using RAM. It would still be some ways off though.

If you don't want that though do you have any recommendations on how to solve the issue without modification?

Try swww img --transition-type=none. The transition will finish instantly. But note that decoding the image takes quite a while, so it might still not be fast enough.

I've tried copying the files to a RAM filesystem on load but I haven't noticed any difference

Right. Reading the files is not the problem; decoding them is. Decoding is currently the slowest part of the pipeline to get something to the daemon when you call swww img.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants