mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-02 21:40:41 +01:00
96e95edac4
## 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.