Reset maxAtlasPages after tests that lower it

setMaxAtlasPages mutates a static that lives for the page's lifetime, so a
lowered cap silently leaked into every renderer built by later tests in the
same file (their GL texture and shader sampler arrays were sized at the tiny
cap, making tests order-dependent). Add resetMaxAtlasPages and call it in
afterEach wherever the cap is lowered on a shared page.
This commit is contained in:
Anthony Kim
2026-07-04 13:04:11 -07:00
parent f9b043274d
commit fab7bc3c5a
5 changed files with 31 additions and 8 deletions
@@ -23,6 +23,7 @@ import {
captureRowSignatures,
expectSignatureMatches,
loadWebglStrict,
resetMaxAtlasPages,
setMaxAtlasPages,
writeAndWaitForRender
} from '../../../test/playwright/RendererTestUtils';
@@ -96,13 +97,7 @@ test.describe('atlas page overflow (#322756 class)', () => {
} finally {
ctx.page.off('pageerror', onError);
// Restore the default so a lowered cap can never leak into other tests.
await ctx.page.evaluate(() => {
const renderer = (window as any).term._core._renderService._renderer.value;
const atlas = renderer?._charAtlas;
if (atlas) {
(atlas.constructor as any).maxAtlasPages = undefined;
}
}).catch(() => { /* page may already be unusable after a crash */ });
await resetMaxAtlasPages(ctx).catch(() => { /* page may already be unusable after a crash */ });
await ctx.page.close();
}
});
@@ -23,6 +23,7 @@ import {
expectSignatureMatches,
floodDistinctGlyphs,
loadWebglStrict,
resetMaxAtlasPages,
setMaxAtlasPages,
waitForRender,
writeAndWaitForRender
@@ -45,6 +46,9 @@ test.describe('WebGL glyph + atlas integrity', () => {
await loadWebglStrict(ctx);
});
// A lowered page cap must not leak into renderers built by later tests.
test.afterEach(async () => await resetMaxAtlasPages(ctx));
test('renders distinct, non-blank glyphs', async () => {
await writeAndWaitForRender(ctx, 'A W .');
await assertTextureAtlasPresent(ctx);
@@ -14,7 +14,7 @@
*/
import test, { expect } from '@playwright/test';
import { ITestContext, createTestContext, openTerminal } from '../../../test/playwright/TestUtils';
import { captureRowSignatures, expectSignatureMatches, getAtlasPageCount, loadWebglStrict, setMaxAtlasPages, writeAndWaitForRender } from '../../../test/playwright/RendererTestUtils';
import { captureRowSignatures, expectSignatureMatches, getAtlasPageCount, loadWebglStrict, resetMaxAtlasPages, setMaxAtlasPages, writeAndWaitForRender } from '../../../test/playwright/RendererTestUtils';
import { generateColoredAsciiFlood } from '../../../test/playwright/SyntheticTui';
const HEADER = ' HEADER_REF_0123456789';
@@ -27,6 +27,9 @@ test.describe('single-terminal merge integrity (#322756 class)', () => {
test.skip(({ browserName }) => browserName !== 'chromium');
test.describe.configure({ timeout: 60000 });
// A lowered page cap must not leak into renderers built by later tests.
test.afterEach(async () => await resetMaxAtlasPages(ctx));
test('pinned header renders identically across 30 merge-heavy body redraws', async () => {
await openTerminal(ctx, { cols: 80, rows: 24 });
await loadWebglStrict(ctx);
@@ -16,6 +16,7 @@ import {
floodDistinctGlyphs,
getAtlasPageCount,
loadWebglStrict,
resetMaxAtlasPages,
setMaxAtlasPages,
waitForRender,
writeAndWaitForRender
@@ -37,6 +38,9 @@ test.describe('WebGL single-terminal heavy render + merge', () => {
await loadWebglStrict(ctx);
});
// A lowered page cap must not leak into renderers built by later tests.
test.afterEach(async () => await resetMaxAtlasPages(ctx));
test('heavy merge churn must not crash the GlyphRenderer (vscode#322756)', async () => {
// Guard: heavy merges must not throw from GlyphRenderer.render. Note the
// page cap here is lowered AFTER the renderer was built, so _atlasTextures
+17
View File
@@ -292,6 +292,23 @@ export async function setMaxAtlasPages(ctx: ITestContext, maxAtlasPages: number)
expect(applied, 'should be able to reach the texture atlas to set maxAtlasPages').toBe(true);
}
/**
* Resets `maxAtlasPages` to undefined so the next constructed renderer re-derives it from GL
* capabilities. Call after any test that used {@link setMaxAtlasPages}: the static lives for
* the page's lifetime, so without a reset every terminal opened later in the same file builds
* its GL texture and shader sampler arrays at the lowered cap.
* @param ctx The test context.
*/
export async function resetMaxAtlasPages(ctx: ITestContext): Promise<void> {
await ctx.page.evaluate(() => {
const renderer = (window as any).term?._core?._renderService?._renderer?.value;
const atlas = renderer?._charAtlas;
if (atlas) {
(atlas.constructor as any).maxAtlasPages = undefined;
}
});
}
/**
* Writes `chunks` screenfuls of distinct glyphs, rendering after each chunk.
*