Skip to content

fix(image): free empty shelf pages and forget dropped or undrawn images on shared atlas pages - #2107

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

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

Conversation

@opencodejr

@opencodejr opencodejr Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #2103.

ImageAtlas (crates/rune-image/src/pixels.rs) held memory for images up to 1024×1024 in two ways. This PR changes three things:

  • Empty shelf pages free their buffer at the end of the frame. end_frame now frees data on an empty shelf page at any index above 0, even when a later page is still in use. Before, only oversized pages did this, and other empty pages waited for rest(). With the buffer gone, Renderer::upload_images drops that page's texture. The first page keeps its buffer, as before. allocate already rebuilds a page whose buffer is empty, so the freed page takes new images.
  • Dropped images are forgotten wherever they sit. Slot now holds a Weak<FrameInner>. end_frame and rest drop a slot once every Pixels handle for that image is gone, even on a page another image still draws from. Its starts entry goes with it.
  • rest decides per slot. Slot now tracks touched/shown the way ImagePage does. rest forgets every image the last frame didn't draw, including ones that share a page with an image that was drawn. Images that were drawn keep their place, so nothing on screen moves.

Unchanged on purpose: end_frame still keeps undrawn but live images on a page that's in use, so a view you come back to needs no copy (an_image_shown_again_after_a_while_is_not_copied_again). Space freed on a page that's still in use is only reused once the whole page empties. Reusing it sooner would mean moving live images within the page.

Testing

  • New tests in pixels_tests.rs: an_empty_shelf_page_below_one_still_shown_frees_its_buffer and images_dropped_or_not_shown_beside_one_still_shown_are_forgotten. Both fail on dev without the change and pass with it.
  • cargo test -p rune-image: all pass (87 + 10, 2 ignored).
  • cargo clippy -p rune-image --lib --tests: no new warnings. scripts/file-size.sh: passes.
  • Not run: cargo test -p rune. It compiles, but the sandbox has no libxkbcommon, so linking fails.

Changelog: changelog/unreleased/2026-11-25-image-atlas-reclaim.md.

Fixes #2103

@thdxr

thdxr commented Nov 25, 2026

Copy link
Copy Markdown
Member

closing, dev already has this: #2115 frees empty shelf pages above a page still in use, and #2124 tracks each slot's pixels weakly with per-slot shown/touched, so dropped or undrawn images on shared pages are already forgotten in end_frame and rest

@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.

ImageAtlas retains empty <= 1024x1024 shelf pages when higher pages are active and never evicts dead Slots on shared pages

1 participant