Skip to content

wallpapers/image: Introduce TransientImage

Wallpapers are pretty big images, they may need a quite substantial amount of RAM to be stored.

However, we need to keep wallpaper images in RAM only for a short period of time, until the images are uploaded to textures.

Another issue is that with fractional scaling on Wayland, wallpaper images can occupy more than necessary of RAM. For example, consider a 4K monitor with resolution 3840x2160. Ideally, it should only need 31.6MiB ((3840 * 2160 * 4) / 1024 / 1024). If use 125% scale factor, then 81MiB ((3840 / 1.25 * 2 * 2160 / 1.25 * 2 * 4) / 1024 / 1024) will be needed to store the wallpaper in RAM.

If you use an image provider for a wallpaper, then even more RAM will be wasted because QQuickImage has undocumented behavior where it scales the Image.sourceSize. For example, with the previous example, 126.5MiB ((3840 / 1.25 * 2 * 1.25 * 2160 / 1.25 * 2 * 1.25 * 4) / 1024 / 1024) will be needed to store a wallpaper if it is provided by an image provider.

This change introduces a specialized image item for wallpapers. When the image data is uploaded to a texture, it'll be dropped. It also doesn't have any quirks wrt device pixel ratio. If you use fractional scaling on wayland, then plasma won't allocate more than necessary memory for the image data.

On my machine, after system startup, this reduces the amount of used RAM by plasmashell from 420MiB to 280MiB.

Edited by Vlad Zahorodnii

Merge request reports

Loading