Skip to content

Fit a mounted terminal pane from a task, never inside an animation frame - #1859

Open
nedtwigg wants to merge 1 commit into
mainfrom
chrome-flash
Open

nedtwigg wants to merge 1 commit into
mainfrom
chrome-flash

Conversation

@nedtwigg

Copy link
Copy Markdown
Member

Every split on the desktop playground still flashed the other terminals blank in Chrome, even after #1839.

Cause

The Lath animator reports that a split has settled from inside its requestAnimationFrame callback, and TerminalPane ran its fit right there. When an entering pane's first resize (away from xterm's default 80×24) happens inside that callback, Chromium's TreesInViz compositor fails has_damage (crbug.com/454680865: "Has no damage while expects_to_draw is set") and skips draws. Every other WebGL terminal canvas shows blank until something forces a fully damaged frame. #1839 moved WebGL acquisition after the first fit, which shortened a lasting blank to a 130 ms–2 s flash; its 1 s samples missed that.

The entering pane's renderer doesn't matter: kept on the DOM renderer, it still blanked the others for about 2 s. Deferring the fit to the next animation frame still blanked; a setTimeout(0) task did not.

Fix

Evidence

Counted from CDP Page.startScreencast frames on the desktop playground, per pane:

Browser Before After
Chrome for Testing 150 (TreesInViz on by default) all three existing terminals blank on 5/5 splits, 128–2143 ms 0 of 12 splits
Chrome 157 + --enable-features=TreesInViz blank on every split, 133–2134 ms 0 of 15 splits (5 headless, 10 headed)
Chrome 157 defaults, or --disable-features=TreesInViz none —
DOM renderer none —

Zoom, unzoom, and minimize/reattach still don't blank. No xterm rollback is needed: the current pins are clean once the fit moves to a task.

Testing

  • A new TerminalPane.test.tsx case checks that no fit or renderer acquisition happens inside an animation-frame callback during a split; it fails against the old code.
  • pnpm test in lib (including tsc -b) and website, pnpm lint:specs, and pnpm lint:md pass.
  • Confirmed by hand in agent-browser's Chrome for Testing on the playground.
  • Not tested: the music-video iframe pane (absent from the headless layouts), Firefox, the Tauri app, VS Code. On the first split, ascii-splash still goes blank for 1–2 frames, which also happens on the DOM renderer and without TreesInViz, so it looks like the program redrawing after its resize.

🤖 Generated with Claude Code

Every split on the desktop playground still flashed the other terminals
blank in Chrome. The Lath animator signals settlement from inside its
requestAnimationFrame callback, and TerminalPane fit there. In Chromium's
TreesInViz compositor (crbug.com/454680865) an entering pane's first
resize inside that callback makes Viz skip draws, so every other WebGL
terminal canvas shows blank until something forces a fully damaged
frame. #1839 moved WebGL acquisition after the first fit, which turned a
lasting blank into a 130 ms - 2 s flash that 1 s samples missed.

TerminalPane now runs the coordinator-woken fit and its mount fit from
a zero-delay task. Measured from CDP screencast frames on the desktop
playground: Chrome for Testing 150 (TreesInViz on by default) blanked all
three existing terminals on every split, now none in 12 splits; Chrome
157 with --enable-features=TreesInViz likewise, now none in 15. Without
TreesInViz, or on the DOM renderer, it never blanked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: b898c2c
Status: ✅  Deploy successful!
Preview URL: https://253fb541.mouseterm.pages.dev
Branch Preview URL: https://chrome-flash.mouseterm.pages.dev

View logs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants