Skip to content

fix(render): drop GPU textures of image pages freed when a window rests - #2108

Closed
opencodejr[bot] wants to merge 1 commit into
devfrom
bot/issue-2102
Closed

opencodejr[bot] wants to merge 1 commit into
devfrom
bot/issue-2102

Conversation

@opencodejr

@opencodejr opencodejr Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #2102.

ImageAtlas::rest() frees the CPU copy of image pages no element showed in the last frame (and truncates pages). But Renderer::give_back never touched Renderer::images, and no frame is drawn while a window rests or is hidden. So those pages' GPU textures stayed resident until the next drawn frame's upload_images.

Changes

  • Renderer::rest_images(&ImageAtlas) -> bool (render/upload.rs): shortens self.images to the atlas's page count and drops the texture of every page whose data is empty. When anything was dropped it also clears the layers' image bind groups and bumps images_changed(), as clear_images does.
  • Host::give_back (window/host/lifecycle.rs) and OverlayCore::give_back (overlay/lifetime.rs) call it right after rt.images.rest() and before renderer.give_back(...), so with all the existing submit/poll (window) or retire_now (overlay) releases the memory.
  • Changelog entry changelog/unreleased/2026-11-25-rest-drops-image-textures.md.

Pages still on screen keep their textures, including on GiveBackAll. The issue also suggested clear_images() on hidden/covered windows; I left that out because it would make a covered window re-upload every visible image when it comes back. Happy to add it if that trade-off is wanted.

Tests

  • New render::image_tests::rest_drops_textures_of_freed_image_pages: a shelf-page image and an oversized standalone-page image are uploaded. The small one leaves the view, then rest() + rest_images. Checks: the freed page's texture is dropped, the lengths match, the page still showing keeps its texture, a second call drops nothing, and the image re-uploads when it comes back.
  • RUNE_ALLOW_NO_GPU=1 cargo test -p rune --features rune/test-gpu-noop --lib --no-fail-fast: 3002 passed, 0 failed, 13 ignored (wgpu no-op backend; no GPU in the test environment, so real VRAM use was not measured). The full AGENTS.md command, which also covers rune-mermaid and rune-kit, was not run.
  • cargo check -p rune --all-targets and cargo clippy -p rune --lib report nothing on the changed lines; scripts/file-size.sh reports no errors.

Fixes #2102

@thdxr

thdxr commented Nov 25, 2026

Copy link
Copy Markdown
Member

closing, #2126 already does this on dev: give_back now takes the image atlas and drops the textures of pages rest() freed, for both windows and overlays

@thdxr thdxr closed this Nov 25, 2026
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

Successfully merging this pull request may close these issues.

Host::give_back() and OverlayCore::give_back() free CPU ImageAtlas pages without dropping GPU Renderer::images textures

1 participant