garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /docs/notes/texture-lifetime.md

raw


topic: texture-lifetime triggers: [images.rs, ImageCache, IDLE_FRAMES, CAP_BYTES, LiveImages, "has been destroyed", "Validation Error", Queue::submit, render_halt.rs, "frozen app", "halted renderer", "egui-texture-lifetime", free_texture, photo_viewer] updated: 2026-11-26

A texture cannot be freed in the frame that recorded work on it

Destroying a GPU resource is not a drop, and a recorded-but-unsubmitted command buffer is a live user of it. wgpu::Texture::destroy invalidates the resource at once, including for command buffers already recorded and not yet submitted, and wgpu reports it at submit:

Validation Error
  In Queue::submit
    In a draw command, kind: Draw
      Texture with 'egui_texid_Managed(3)' label has been destroyed

render_halt.rs::handle_render_error halts the renderer on Validation (by design โ€” validation errors recur), so the app keeps running with the picture frozen at its last frame and nothing else in the log. On a phone that is indistinguishable from a hang. Not a device loss: the device was healthy and the command buffer was wrong.

How it was found (2026-08-16, Adreno)

Opening a saved place's photo on a phone and closing it froze the app for the rest of its life. egui retired a texture on the end_pass of the frame its last handle was dropped in, and that same pass had just drawn it โ€” dropping the handle was the consequence of the โœ• the pass had drawn. egui_wgpu's free_texture destroyed it before the render graph submitted. The fix queued the frees and drained them at the top of the next pass, past Queue::submit, as egui-wgpu's own winit painter does. egui left the client on 2026-11-26; the rule stayed.

Where it holds now