fix(engine): parallelize forced screenshot workers (#1848)

This commit is contained in:
Miguel Ángel
2026-07-01 19:34:22 -07:00
committed by GitHub
parent 6be46813a2
commit 145c71e837
2 changed files with 70 additions and 12 deletions
@@ -4,6 +4,7 @@ import {
distributeFrames,
formatWorkerFailure,
selectWorkerDiagnostics,
shouldDisableBrowserPoolForParallelWorker,
shouldVerifyWorkerGpu,
} from "./parallelCoordinator.js";
import type { EngineConfig } from "../config.js";
@@ -76,6 +77,44 @@ describe("calculateOptimalWorkers", () => {
});
});
describe("shouldDisableBrowserPoolForParallelWorker", () => {
const linuxHeadlessWorker = {
parallel: true,
platform: "linux" as NodeJS.Platform,
deviceScaleFactor: 1,
headlessShellPath: "/tmp/chrome-headless-shell",
};
it.each([
["BeginFrame", false],
["forced screenshot", true],
])(
"disables the browser pool for parallel Linux/headless %s workers",
(_mode, forceScreenshot) => {
expect(
shouldDisableBrowserPoolForParallelWorker({
...linuxHeadlessWorker,
forceScreenshot,
}),
).toBe(true);
},
);
it.each([
["non-parallel", { parallel: false, forceScreenshot: true }],
["non-linux", { platform: "darwin" as NodeJS.Platform, forceScreenshot: true }],
["no headless shell", { headlessShellPath: undefined, forceScreenshot: true }],
["supersampled", { deviceScaleFactor: 2, forceScreenshot: false }],
])("keeps the shared pool for %s workers", (_case, overrides) => {
expect(
shouldDisableBrowserPoolForParallelWorker({
...linuxHeadlessWorker,
...overrides,
}),
).toBe(false);
});
});
describe("worker failure diagnostics", () => {
it("keeps only actionable worker diagnostics and caps the tail", () => {
const diagnostics = selectWorkerDiagnostics(