# Fix crash in WgpuAtlas when viewing a screen share \(\#53088\) · gitcafe/zed

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

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

Visibility: public

Requested revision: e4ebd3aae5c243087940f48de5cf27c46a569525

Requested commit: e4ebd3aae5c243087940f48de5cf27c46a569525

Commit: e4ebd3aae5c243087940f48de5cf27c46a569525

Tree: e3803b7a24c203503bde9a747a37bf468736fec7

Author: Oleksiy Syvokon

Committer: GitHub

## Message

````
Fix crash in WgpuAtlas when viewing a screen share (#53088)

When atlas tiles are rapidly allocated and freed (e.g. watching a shared
screen in Collab), a texture can become unreferenced and be removed
while GPU uploads for it are still pending. On the next frame,
`flush_uploads` indexes into the now-empty texture slot and panics:

```
  thread 'main' panicked at crates/gpui_wgpu/src/wgpu_atlas.rs:231:40:
  texture must exist...

  #11 core::option::expect_failed
  #12 gpui_wgpu::wgpu_atlas::WgpuAtlas::before_frame
  #13 gpui_wgpu::wgpu_renderer::WgpuRenderer::draw
```

This change drains pending uploads for a texture when it becomes
unreferenced in `remove`, and skips uploads for missing textures in
`flush_uploads` as a safety net.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable


Release Notes:

- Fixed occasional crashes when viewing a screen share
````

## Parents

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

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