Repository navigation
offscreen: Release the render target on close and close dropped windows - #37
Merged
Merged
Conversation
The headless renderer lives for the rest of the process, so after a capture it kept the render target and path textures sized to the last frame (a long image is hundreds of megabytes of GPU memory) and every glyph and image tile uploaded to the atlas the offscreen windows share: GPUI only removes image tiles through `App::drop_image` on open windows, which never reaches it once the window is gone. Add `WgpuHeadlessRenderer::release_render_target` and `clear_sprite_atlas` to the vendored `gpui-pre-wgpu`, and call both when GPUI drops the last offscreen platform window. The device and pipelines are kept for the next capture. `OffscreenWindow` now closes its window when dropped without `close` (for example when the task holding it is cancelled). `Drop` has no `App`, so it spawns the close on the foreground executor; `close` disarms it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #33.
App::drop_imageon open windows, which never reaches that atlas once the window is gone, so image tiles accumulated for the life of the process.gpui-pre-wgpugains twooffscreen-gated methods onWgpuHeadlessRenderer:release_render_target(render target + path intermediates) andclear_sprite_atlas(atlas tiles + the cached bind groups that keep their textures alive). The readback buffer was already a per-call local, so there is no staging buffer to release.offscreencounts live offscreen platform windows and calls both when GPUI drops the last one (after its view tree), so no open window can hold a tile that gets cleared. The device and pipelines stay for the next capture.OffscreenWindowwithoutclose(for example when the task holding it is cancelled) used to leave the window and its view tree alive forever. It now keeps anAsyncAppand, on drop, spawns the close on the foreground executor, sinceDropmay run while theAppis borrowed.closedisarms it, so the window is never closed twice.[patch.crates-io]comment describe the new vendor methods and the release behaviour.While an offscreen window stays open, image tiles still accumulate the same way they do for on-screen windows; the instance buffer, which grows to the largest frame's instance data, is kept with the pipelines.
Testing
cargo check --features offscreenforaarch64-apple-ios,aarch64-apple-ios-simandaarch64-linux-androidcargo check --all-targets,cargo test --lib,cargo fmt --all -- --checkcargo clippy --features offscreenfor iOS and Android: no new warningsheadless_renderer_releases_frame_textures(Linux, like the other headless tests); also run locally on macOS against a Metal instance, where it passes