Repository navigation
Fix the blade-atlas zoom crash and the memory growth while painting - #92
Merged
Merged
Conversation
…red image slots Rapid keyboard zoom crashed in gpui's blade atlas: every ctrl+minus rebuilt the window-sized viewport image, and each rebuild created and destroyed a dedicated GPU texture, racing the atlas's deferred texture initialization. The fork side is fixed at the newly pinned gpui rev (removal now cancels a dead texture's pending work and the flush skips freed slots); this commit removes the churn and the leaks that fed it: - Zoom entry points that skipped the 120 ms view-gesture damping (ZoomIn/ ZoomOut actions, the zoom tool, the menu bar, the navigator slider) now arm it like wheel and pinch zoom, so a burst of steps stretches the previous image and rebuilds once settled. - Dropping an Arc<RenderImage> never frees its atlas slot; every site that did so now routes through retire_image/drop_image: the layer and navigator thumbnails (rebuilt on every brush dab, the main source of memory growth while painting), the far-zoom preview image, the empty-viewport branch, and the viewport invalidation in rotate-view, colour-transform rebuilds and per-document cache resets. prepare_paint drains the retired list even with no document open. - Undo history gains a byte budget (1 GiB) alongside the 200-edit cap: one stroke can retain tens of megabytes of before/after tiles, so the count cap alone let painting sessions hold gigabytes. - The preview dirty-rect list, only drained at far zoom, now collapses to a full-rebuild flag past 256 rects instead of growing per dab forever. Verified headlessly (Xvfb + lavapipe): 26 rapid zoom keys now cause zero atlas rebuilds and no crash; 24 settled zooms cycle textures through the fixed removal path cleanly; brush-stroke memory growth is down to bounded undo retention. Co-Authored-By: Claude Fable 5 <[email protected]>
IAmJSD
force-pushed
the
t3code/f1761022
branch
from
September 2, 2026 16:11
15f9df9 to
399f96a
Compare
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
A user crash report showed the app panicking at
blade_atlas.rs:229(Option::unwrap()onNone) after a burst of atlas-texture churn during zooming. This PR fixes the crash in the gpui fork and removes the schist-side churn and leaks that fed it, which were also the main cause of memory growth while painting brush strokes.gpui fork (fix landed as
6a7092a;mainalready pins73c9da6, which contains it, so this PR no longer touches Cargo.toml)An image too big for the shared 1024² atlas page gets a dedicated texture, queued for init/upload and drained at the next frame flush. Removing the image in between destroyed the texture slot, and the flush panicked indexing the empty
Option. Removal now cancels the dead texture's pending work and returns the tile's rectangle to the allocator (shared atlases never reclaimed space before), and both flush paths skip freed slots — mirroring upstream zed's wgpu atlas.schist
ZoomIn/ZoomOutactions, the zoom tool, the menu bar and the navigator slider now arm the existing 120 ms view-gesture settle like wheel/pinch zoom, so rapid zoom stretches the previous image and rebuilds once instead of creating/destroying a window-sized (~8 MB) texture per step.Arc<RenderImage>never frees its atlas slot. Every site that silently dropped one now routes throughretire_image→drop_image: the layer/navigator thumbnails (rebuilt on every brush dab — the primary painting-memory leak), the far-zoom preview, the empty-viewport branch, and viewport invalidation on rotate-view, colour-transform rebuilds and per-document cache resets.preview.dirtycap: the list is only drained at far zoom; it now collapses to a full-rebuild flag past 256 rects instead of growing per dab forever.Testing
cargo check,cargo fmt -- --check, pinch + wayland unit tests,cargo check --target x86_64-pc-windows-gnuall clean.make buildclean; 856 workspace tests pass, 0 failures.ctrl+minuscrash recipe): 26 rapid zoom keys → zero atlas rebuilds, no crash (previously one texture create/destroy per press, then the panic); 24 settled zooms → 12 create/destroy cycles through the fixed removal path, no crash; 15 brush strokes → remaining growth is bounded undo retention only.Follow-ups (not in this PR)
TileCache/display_tiles.Stroke.coverageand borrowingInkinstead of cloning aTileMapper tile per dab.🤖 Generated with Claude Code