Repository navigation
fix(chrome): stop unbounded PTY memory growth and Windows ConPTY freezes - #85
Draft
StephenSHorton wants to merge 1 commit into
Draft
StephenSHorton wants to merge 1 commit into
StephenSHorton wants to merge 1 commit into
Conversation
The reader thread used an unbounded channel and drained every queued chunk in one UI wake, so a fast child (Grok, yes, ConPTY bursts) could grow RSS until the machine OOM'd. Native ResizePseudoConsole also ran on every animated layout frame while ReadFile was hot — the same class of Windows hard-kill the Go host already gated. Cap the PTY queue and per-wake drain, debounce/skip Windows resize while I/O is recent, and keep scrollback / VT hold / CSI params bounded. Reuse the rain bind group and poll wgpu so Metal staging buffers do not accumulate. Add mem_bound regression tests. Co-authored-by: Stephen Horton <StephenSHorton@users.noreply.github.com>
This branch has not been deployed
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.
The macOS OOM and the Windows freeze/crash share one primary cause in the Rust chrome host, plus a Windows-only ConPTY hazard.
Root causes
Unbounded PTY queue (macOS OOM, Windows freeze)
The reader thread used
mpsc::channelwith no cap andtry_readdrained every queued chunk in one UI wake. A fast child (Grok alt-screen,yes, ConPTY bursts) could allocate without bound while the UI was busy painting per-cell glyphon text. Memory grew until the Mac died; on Windows the same backlog made the event loop look frozen, then the machine could OOM.Hot
ResizePseudoConsoleduring animated layout (Windows freeze / hard kill)sync_grids_to_panesruns on every redraw. Jelly splits change cols/rows every frame and immediately calledportable-ptyresize. ConcurrentResizePseudoConsole+ hotReadFileis the same class of native death documented indocs/windows-stability-swarm-report.mdfor the old Go host. The Go session already has a 300ms quiet gate; the Rust chrome path did not.Secondary bounds that could grow under garbage/TUI streams:
;floods could growcsi_paramsdevice.poll()’d after presentBuffers stayed at the high-water mark after a large TUIWhat changed
sync_channel, 128 × 8 KiB ≈ 1 MiB). Reader blocks instead of allocating.Maintain::Pollafter present; glyphon atlas trim every ~2 s; text buffers shrink after a large window.mem_bound+ unit tests: 80k-line storm stays ≤ 2000 scrollback rows; PTY/resize/hold/CSI caps.Verification
cargo test --lib --locked— 402 passed (includesmem_bound, PTY policy, CSI flood, scrollback storm).cargo check --locked --binson Linux.cargo check --locked --lib --target x86_64-pc-windows-gnu— Windowscfgresize-defer path typechecks.Could not run the GPU window on this VM, so there are no before/after RSS numbers from a live Suzuri session. The 80k-line storm keeps the grid under
max_grid_bytes(~5–6 MiB of cells). The old unbounded PTY queue had no ceiling.Needs real-machine testing
yes/ Grok alt-screen. Activity Monitor RSS should plateau (queue ≤ ~1 MiB + 2000-line scrollback), not climb to OOM.Open issues
The repo has no open GitHub issues. The only open PR is #84 (Rock / OSC 7880), unrelated. The old Windows stability write-up is about the Go ConPTY host; this PR applies the same fail-closed resize idea to the Rust chrome path that actually owns the window now.