Skip to content

Render a blank renderer right away while paused - #6240

Open
Bokjan wants to merge 5 commits into
xtermjs:masterfrom
Bokjan:paused-blank-render
Open

Bokjan wants to merge 5 commits into
xtermjs:masterfrom
Bokjan:paused-blank-render

Conversation

@Bokjan

@Bokjan Bokjan commented Oct 17, 2026

Copy link
Copy Markdown

Fixes #6239.

While a terminal is paused, RenderService defers refreshes until the IntersectionObserver reports it back on screen, which happens after the first frame it is visible in is painted. That's harmless while the canvas still holds the last frame, but it leaves the terminal blank for that frame when the renderer has nothing to show:

  • setRenderer while paused: the new renderer starts out empty. Apps that keep the WebGL renderer only for visible terminals, to stay within the WebGL context limit, do this whenever a terminal is shown.
  • A sync redraw while paused: Force a sync render after resize occurs #5529 asks for one when the WebGL addon's ResizeObserver resizes the canvas, which clears it, but refreshRows dropped it while paused.

Both now render synchronously while paused: refreshRows with sync runs the paused resize and renders, still marking a full refresh for when rendering resumes, and setRenderer renders right away when paused. Other refreshes still wait for the pause to end.

Verification

  • npm run test-unit, with the new RenderService.test.ts: while paused, a new renderer and a sync redraw (after a paused resize) render right away, and other refreshes wait for the observer; while not paused, a new renderer renders on the next frame. The first two fail without the change.
  • npm run lint-changes
  • The repro from the issue, built against this branch and against master, in Chrome 155 on Windows 11, recording each frame with Page.startScreencast: in 6 switches each, master showed 6 blank frames at pixel ratios of 1 and 1.75, this branch none.

🤖 Generated with Claude Code

While paused, RenderService defers refreshes until the IntersectionObserver reports the terminal back on screen, a frame after it is visible. A new renderer set while paused, or a sync redraw requested after its canvas was cleared, then showed the terminal blank for that frame. Both now render synchronously while paused.

Fixes xtermjs#6239

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@xtermjs-bot xtermjs-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blank-frame fix works when nothing is waiting in the paused resize queue. It stack-overflows when a paused resize runs, because that resize asks for the same sync redraw that now flushes the queue. Details and the two requested changes are inline.

Verified on 9fc122d2 merged cleanly onto current master (f211a26a). Lint is clean. Unit tests: 2474 passing, including the four new RenderService tests. Playwright test/playwright/Terminal.test.ts with --suite=core: 207 passed on Chromium, Firefox, and WebKit. --suite=addon-webgl: 67 passed, 161 skipped (Firefox and WebKit are skipped by that suite), 0 failed.

The issue repro is fixed. Swapping a WebglAddon between two off-screen-paused terminals: on master every switch painted a blank frame (device pixel ratio 1 and 1.75); on this branch every switch painted text. The PR recording's only blank frame is before the first paint.

The overflow reproduced two ways, and not on master:

  • A unit-test renderer whose handleResize emits a sync redraw. A sync redraw with a paused resize queued, the idle callback of that resize, and setRenderer while one is queued each re-enter handleResize. On master they do not re-enter; the sync redraw is still dropped.
  • In Chromium, a visible WebGL terminal moved off-screen (paused === true) and then resized. Master returns and, once shown, still draws. This branch throws from the idle callback.

Any paused WebGL terminal that is resized hits this, not only the show-and-swap repro.

Recordings (master, then this PR):

master-paused-resize.webm
pr-paused-resize.webm
master-blank-frame.webm
pr-blank-frame.webm

Comment thread src/browser/services/RenderService.ts Resolved
Bokjan and others added 2 commits October 30, 2026 00:13
Renderers such as the WebGL one request a sync redraw at the end of handleResize. When the paused resize task ran that, the sync redraw flushed the task again and handleResize recursed until the stack overflowed. The redraw a renderer requests from handleResize now only renders; setRenderer and other sync redraws with a resize queued still flush it once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Bokjan

Bokjan commented Oct 29, 2026

Copy link
Copy Markdown
Author

Updated

@Bokjan

Bokjan commented Nov 14, 2026

Copy link
Copy Markdown
Author

@Tyriar Friendly ping: both requested changes from the bot review are addressed in 4f67815 (replies are on the two inline threads), and the branch is up to date with master. Could you take another look, or rerun the review, when you have time? CI also needs workflow approval since this is my first contribution here. Thanks!

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.

Terminal is blank for a frame when a renderer is set while the render service is paused

1 participant