mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
9294a7130f
Each terminal that loads the WebGL addon holds a live WebGL context for its whole lifetime, and all session panes stay mounted (hidden ones off-screen). Batch connect therefore created a WebGL context per host up front, contending for the GPU on the main thread — also the root of the "garbled / 花屏" corruption in #1049/#1063. Defer WebGL creation for panes that mount hidden (background tabs of a batch) and upgrade them on first visibility via an idempotent ensureWebglRenderer(); a hidden pane renders through xterm's DOM renderer until shown. Visible panes (single connect, the active tab) keep creating WebGL immediately — unchanged behavior. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
818 B
TypeScript
30 lines
818 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { shouldDeferWebglUntilVisible } from "./webglRendererPolicy";
|
|
|
|
test("defers WebGL for a pane that mounts hidden", () => {
|
|
assert.equal(
|
|
shouldDeferWebglUntilVisible({ useWebGLAddon: true, initiallyVisible: false }),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("loads WebGL immediately for a visible pane (unchanged behavior)", () => {
|
|
assert.equal(
|
|
shouldDeferWebglUntilVisible({ useWebGLAddon: true, initiallyVisible: true }),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("never defers when WebGL is not used at all", () => {
|
|
assert.equal(
|
|
shouldDeferWebglUntilVisible({ useWebGLAddon: false, initiallyVisible: false }),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
shouldDeferWebglUntilVisible({ useWebGLAddon: false, initiallyVisible: true }),
|
|
false,
|
|
);
|
|
});
|