# gpui: Skip sprites whose atlas texture was released instead of panicking \(\#64623\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/96e95edac45b0e0696179b8139aa521cf48db392)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 96e95edac45b0e0696179b8139aa521cf48db392

Requested commit: 96e95edac45b0e0696179b8139aa521cf48db392

Commit: 96e95edac45b0e0696179b8139aa521cf48db392

Tree: 0788ef2d161e071472d8c3aecdaf6ebe43d76ef4

Author: Mikayla Maki

Committer: GitHub

## Message

```
gpui: Skip sprites whose atlas texture was released instead of panicking (#64623)

## Objective

Each rendering backend looked up the atlas texture for a sprite batch
with an `unwrap`, so a scene referencing a texture the atlas had already
released aborted the process (`metal_atlas.rs:196` in the Delta crash
reports). This happens when an image is dropped while a cached view
still replays a paint from before the drop — Delta hit it when
re-rasterizing a zoomed Mermaid diagram.

## Solution

Texture lookups now return `Option`, and the Metal, wgpu, and DirectX
sprite draws skip a batch whose texture is gone. The stale paint is
replaced as soon as its view re-renders, so nothing is lost beyond that
frame. wgpu also drops the cached bind group for a released texture and
no longer fails the whole frame on a missing one.

This is a renderer-level safety net and is complementary to #64619,
which fixes the lifetime rule in `Window` so that atlas entries are not
released while a retained frame still references them. Both can land
independently.

## Testing

- `corgi test -p gpui_apple metal_atlas` — 4 passed, including a new
regression that the lookup reports `None` after the last tile is
removed.
- `cargo test -p gpui_wgpu wgpu_atlas` — 5 passed (extended the
generation test to assert `None` after removal).
- `corgi check -p gpui_wgpu`.
- DirectX changes are the same shape but have **not been compiled**; no
Windows target available.

Release Notes:

- N/A
- [GPUI] Fixed a crash when an image was removed from the sprite atlas
while a cached view still referenced it.
```

## Parents

- [e5221fa2956cd8ec88b459de0258a71fea5294de](https://git.cafe/gitcafe/zed/commit/e5221fa2956cd8ec88b459de0258a71fea5294de?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/96e95edac45b0e0696179b8139aa521cf48db392?format=markdown)
