Repository navigation
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
Closed
opencodejr[bot] wants to merge 1 commit into
opencodejr[bot] wants to merge 1 commit into
Conversation
…es on shared atlas pages
Member
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.
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:end_framenow freesdataon 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 forrest(). With the buffer gone,Renderer::upload_imagesdrops that page's texture. The first page keeps its buffer, as before.allocatealready rebuilds a page whose buffer is empty, so the freed page takes new images.Slotnow holds aWeak<FrameInner>.end_frameandrestdrop a slot once everyPixelshandle for that image is gone, even on a page another image still draws from. Itsstartsentry goes with it.restdecides per slot.Slotnow trackstouched/shownthe wayImagePagedoes.restforgets 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_framestill 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
pixels_tests.rs:an_empty_shelf_page_below_one_still_shown_frees_its_bufferandimages_dropped_or_not_shown_beside_one_still_shown_are_forgotten. Both fail ondevwithout 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.cargo test -p rune. It compiles, but the sandbox has nolibxkbcommon, so linking fails.Changelog:
changelog/unreleased/2026-11-25-image-atlas-reclaim.md.Fixes #2103