fix(renderer): invalidate layer/image caches on canvas reset

After a Wayland surface re-creation (tray hide/show, miniplayer cycle),
reset_canvas swapped in a fresh canvas but kept graphics_cache and
texture_cache entries whose textures belong to the OLD canvas's image
store. A cache-rendering-hint layer (Sidebar/HeaderBar/NowPlayingBar
since e3257631) then blits a dangling image id: the subtree goes
invisible while layout and hit-testing keep working — exactly the
reported 'sidebar content does not render' after a
miniplayer->theme->sidebar journey. set_window_adapter and
clear_graphics_context already clear both caches; reset_canvas now does
too (layers re-render, images re-upload once per re-creation).

km
This commit is contained in:
vicrodh committed 2026-07-19 19:11:51 -06:00
1 parent cd4a0494a2
commit 2d747368bf
1 file changed
+11
+11
View File
@@ -665,6 +665,17 @@ impl<B: GraphicsBackend> FemtoVGRenderer<B> {
// store — drop it first (its own Rc keeps that canvas alive for the
// delete_image in Texture::drop).
self.persistent_scene.borrow_mut().take();
// Every cached texture (cached layers, images) also belongs to the OLD
// canvas's image store: after a surface re-creation (Wayland hide/show,
// miniplayer cycle) their image ids are dangling on the new canvas —
// a cache-rendering-hint layer then blits a missing image and the whole
// subtree goes invisible while layout/hit-testing keeps working. Clear
// both caches so layers re-render and images re-upload on the new
// canvas (one-time cost per re-creation).
let _ = self.graphics_backend.with_graphics_api(|_| {
self.graphics_cache.clear_all();
self.texture_cache.borrow_mut().clear();
});
// #617 stage 4: new canvas/context — the partial caches are stale.
if let Some(state) = self.partial_rendering_state.as_ref() {
state.clear_cache();