fix(studio): the viewport gate tells a virtualized timeline by its mounted rows, not its clips (#8511)

* test(studio): the viewport gate reads a virtualized timeline as on while its rows fill at load

* fix(studio): the viewport gate tells a virtualized timeline by its mounted rows, not its clips
This commit is contained in:
Miguel Ángel
2026-11-22 15:06:47 +00:00
committed by GitHub
parent 2b1495f7af
commit dd77990373
3 changed files with 27 additions and 9 deletions
@@ -123,6 +123,11 @@ export function describeAgainstBase({ head, base, interactions, frameIntervals,
].join(", ");
}
/** Which build is measured: a row-virtualized timeline mounts only the rows in view, an unvirtualized one every row. */
export function rowVirtualizationOf({ mountedRows }, budgets) {
return mountedRows <= budgets.maxMountedRows ? "on" : "off";
}
/** A failed timing attempt is measured once more, so one bad stretch of a shared runner cannot fail the gate alone. */
export const TIMING_ATTEMPTS = 2;
@@ -9,6 +9,7 @@ import {
percentile,
shouldCompareWithBase,
responsivenessLimits,
rowVirtualizationOf,
} from "./timeline-viewport-verdict.mjs";
const LIMITS = { samplesPerRun: 63, interactionLimitMs: 75, frameIntervalLimitMs: 75 };
@@ -239,3 +240,16 @@ describe("gatePassed", () => {
expect(gatePassed({ ...passing, attempts: [], againstBase: pass })).toBe(false);
});
});
describe("rowVirtualizationOf", () => {
// fails without the fix: main's gate read this load-time moment of a virtualized base as an unvirtualized build.
it("reads a virtualized timeline as on while its visible rows are full at load", () => {
const atLoad = { mountedRows: 8, mountedClipRoots: 1024, maxMountedClipRootsInOneRow: 128 };
expect(rowVirtualizationOf(atLoad, TIMELINE_VIEWPORT_BUDGETS)).toBe("on");
});
it("reads a timeline that mounts every row as off", () => {
const everyRow = { mountedRows: 1000, mountedClipRoots: 1000, maxMountedClipRootsInOneRow: 1 };
expect(rowVirtualizationOf(everyRow, TIMELINE_VIEWPORT_BUDGETS)).toBe("off");
});
});
@@ -33,6 +33,7 @@ import {
judgeAgainstBase,
judgeResponsiveness,
responsivenessLimits,
rowVirtualizationOf,
shouldCompareWithBase,
TIMING_ATTEMPTS,
timingPassed,
@@ -477,22 +478,20 @@ async function assertProductionRuntime(page) {
}
async function assertRowVirtualization(page, budgets) {
// Trust the DOM, not the caller. A virtualized build cannot mount every clip
// and an unvirtualized one cannot avoid it, so the mounted count says which
// build is really being measured.
const observedClipRoots = await page.evaluate(
() => window.__studioTest.readTimelinePerformanceDiagnostics().mountedClipRoots,
// Trust the DOM, not the caller: the mounted rows say which build is really being measured.
const diagnostics = await page.evaluate(() =>
window.__studioTest.readTimelinePerformanceDiagnostics(),
);
const observedRowVirtualization = observedClipRoots <= budgets.maxMountedClipRoots ? "on" : "off";
const observedRowVirtualization = rowVirtualizationOf(diagnostics, budgets);
if (observedRowVirtualization !== ROW_VIRTUALIZATION) {
throw new Error(
`Requested TIMELINE_ROW_VIRTUALIZATION=${ROW_VIRTUALIZATION} but the server under test ` +
`behaves as ${observedRowVirtualization}: ${observedClipRoots} clip roots mounted for ` +
`${ELEMENT_COUNT} elements against a ${budgets.maxMountedClipRoots} budget. ` +
`behaves as ${observedRowVirtualization}: ${diagnostics.mountedRows} rows mounted for ` +
`${ELEMENT_COUNT} elements against a ${budgets.maxMountedRows} budget. ` +
"Set VITE_STUDIO_TIMELINE_ROW_VIRTUALIZATION_ENABLED on the Studio dev server to match.",
);
}
return observedClipRoots;
return diagnostics.mountedClipRoots;
}
async function waitForFixtureRender(page, elementCount) {