fix(wallpaper): skip ImageHandle::from_rgba when source and fit unchanged#2020
Open
rchennau wants to merge 1 commit into
Open
fix(wallpaper): skip ImageHandle::from_rgba when source and fit unchanged#2020rchennau wants to merge 1 commit into
rchennau wants to merge 1 commit into
Conversation
…or cache leak) ImageHandle::from_rgba always calls Id::unique() (AtomicU64::fetch_add, core/src/image.rs:216), so every UpdateState event during slideshow mode inserted an un-evictable entry into the wgpu raster cache (wgpu/src/image/raster.rs:FxHashMap<image::Id,Memory>), causing ~9 GB/hour RSS growth. Changes: - Add cached_display_key: Option<DefaultKey> and cached_display_fit: Option<usize> to Page struct. - cache_display_image() resolves the effective DefaultKey first, then short-circuits if both key and fit match the previously rendered values. - Sync key/fit fields at all three existing cached_display_handle=None sites (on_leave, ColorAdd, ColorSelect) so state stays coherent. Resolves: DEF-COSMIC-001 fix-path / pop-os#843 See also: pop-os/iced wgpu/src/image/raster.rs (Fix B: trim() vs present() gap)
Member
|
The PR template is mandatory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
cosmic-settings desktopleaks ~9 GB/hour of RSS when running as a persistent background daemon with slideshow mode active. The process is eventually OOM-killed after exhausting swap, which starves the Wayland compositor of CPU time and freezes the display. This is a reproduction of #843.Root Cause
cache_display_image()callsImageHandle::from_rgba()on everyMessage::UpdateStateevent (fired once per wallpaper rotation by the inotify watcher on the cosmic-bg state file).from_rgbaunconditionally callsId::unique():Every call produces a monotonically-increasing unique ID, making cache hits in the wgpu raster cache (
wgpu/src/image/raster.rs—FxHashMap<image::Id, Memory>) structurally impossible.Eviction only happens inside
trim()(raster.rs:78), which is only called fromdraw()(wgpu/src/lib.rs:162), which is only called frompresent(). When the Wayland compositor suppressesRedrawRequestedbetween rotations (DPMS off, occlusion, throttling),present()never fires,trim()never runs, and theFxHashMapgrows unbounded — oneMemoryentry per rotation interval.This is the same
trim()/present()gap described in iced-rs/iced#2659, triggered here by the slideshow rotation path.Fix
Add
cached_display_key: Option<DefaultKey>andcached_display_fit: Option<usize>toPage. At the start ofcache_display_image(), resolve the effectiveDefaultKeyfor the current selection and short-circuit if it matches the previously rendered values:ImageHandle::from_rgbais now called only when the wallpaper or fit mode actually changes, not on every state event. All three existingcached_display_handle = Nonesites are updated to clear the new fields so state stays coherent.Tested
Note on complementary fix
This prevents new unique handles from accumulating. A complementary fix in
pop-os/iced— decouplingtrim()frompresent()so stale entries are evicted even when the compositor suppresses redraws — would provide defence-in-depth (see iced-rs/iced#2659).