Repository navigation
Conversation
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>
There was a problem hiding this comment.
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
handleResizeemits a sync redraw. A sync redraw with a paused resize queued, the idle callback of that resize, andsetRendererwhile one is queued each re-enterhandleResize. 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
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>
|
Updated |
|
@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! |
Fixes #6239.
While a terminal is paused,
RenderServicedefers refreshes until theIntersectionObserverreports 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:setRendererwhile 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.syncredraw while paused: Force a sync render after resize occurs #5529 asks for one when the WebGL addon'sResizeObserverresizes the canvas, which clears it, butrefreshRowsdropped it while paused.Both now render synchronously while paused:
refreshRowswithsyncruns the paused resize and renders, still marking a full refresh for when rendering resumes, andsetRendererrenders right away when paused. Other refreshes still wait for the pause to end.Verification
npm run test-unit, with the newRenderService.test.ts: while paused, a new renderer and asyncredraw (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-changesPage.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