Revert "Clean up image resources for the current window (#45969)" (#46779) (cherry-pick to preview)#46781
Merged
zed-zippy[bot] merged 1 commit intov0.219.xfrom Jan 14, 2026
Merged
Conversation
…6779) This reverts commit 94faaeb. The logic changed in the [original PR](#45969) is either misplaced or lacks a counterpart that reacts on `gpui::Image` drop one way or another. The change was dropping the texture out of the global rendering atlas when an image preview tab was disposed of, while in reality, another instance (agent panel or another image preview tab) could require the very same atlas entry to be rendered meanwhile. Currently, only `RetainAllImageCache` in Zed does any kind of image cleanup, and any other image usages will leak memory. What makes it harder is that the atlas entry needs to live as long as a particular `Arc<Image>` lives, and some public `gpui` API expects this type to stay: https://github.com/zed-industries/zed/blob/e747cfc955e8cfd9327d8d6b8d617cf1d3a6bcaa/crates/gpui/src/platform.rs#L1851-L1866 For image viewer in particular, we need to consider why `RetainAllImageCache` is not used there; for the global, normal fix, we need to consider ways to have `cx` and `window` and a way to react on `Image` drop. As an option, we could break the `gpui` API (as it [happens periodically](#46183) already) and use `Entity<Image>` instead of `Arc`, then react with `cx.on_release_in` for each such image. Closes #46755 Closes #46435 Release Notes: - Fixed panics on concurrent image handling
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.
Cherry-pick of #46779 to preview
This reverts commit 94faaeb.
The logic changed in the original
PR is either
misplaced or lacks a counterpart that reacts on
gpui::Imagedrop oneway or another.
The change was dropping the texture out of the global rendering atlas
when an image preview tab was disposed of, while in reality, another
instance (agent panel or another image preview tab) could require the
very same atlas entry to be rendered meanwhile.
Currently, only
RetainAllImageCachein Zed does any kind of imagecleanup, and any other image usages will leak memory.
What makes it harder is that the atlas entry needs to live as long as a
particular
Arc<Image>lives, and some publicgpuiAPI expects thistype to stay:
zed/crates/gpui/src/platform.rs
Lines 1851 to 1866 in e747cfc
For image viewer in particular, we need to consider why
RetainAllImageCacheis not used there; for the global, normal fix, weneed to consider ways to have
cxandwindowand a way to react onImagedrop.As an option, we could break the
gpuiAPI (as it happensperiodically
already) and use
Entity<Image>instead ofArc, then react withcx.on_release_infor each such image.Closes #46755
Closes #46435
Release Notes: