zed/crates/image_viewer
Kirill Bulatov c35bbaad37
Revert "Clean up image resources for the current window (#45969)" (#46779)
This reverts commit 94faaebfec.

The logic changed in the [original
PR](https://github.com/zed-industries/zed/pull/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:

e747cfc955/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](https://github.com/zed-industries/zed/issues/46183)
already) and use `Entity<Image>` instead of `Arc`, then react with
`cx.on_release_in` for each such image.

Closes https://github.com/zed-industries/zed/issues/46755
Closes https://github.com/zed-industries/zed/issues/46435

Release Notes:

- Fixed panics on concurrent image handling
2026-01-14 11:49:38 +02:00
..
src Revert "Clean up image resources for the current window (#45969)" (#46779) 2026-01-14 11:49:38 +02:00
Cargo.toml Remove workspace-hack (#40216) 2025-10-17 18:58:14 +00:00
LICENSE-GPL Add xtask for finding crates with missing licenses (#11776) 2024-05-13 18:52:12 -04:00