Merge pull request #2521 from heygen-com/fix/stale-compositor-layer

fix(renderer): prevent stale SwiftShader layers
This commit is contained in:
Miguel Ángel
2026-07-16 01:23:59 -04:00
committed by GitHub
7 changed files with 485 additions and 0 deletions
@@ -28,6 +28,25 @@ describe("buildChromeArgs browser GPU mode", () => {
expect(args).not.toContain("--enable-gpu-rasterization");
});
it("disables GPU compositing only for software BeginFrame capture", () => {
const softwareBeginFrame = buildChromeArgs(
{ ...base, captureMode: "beginframe" },
{ browserGpuMode: "software" },
);
const softwareScreenshot = buildChromeArgs(
{ ...base, captureMode: "screenshot" },
{ browserGpuMode: "software" },
);
const hardwareBeginFrame = buildChromeArgs(
{ ...base, captureMode: "beginframe", platform: "linux" },
{ browserGpuMode: "hardware" },
);
expect(softwareBeginFrame).toContain("--disable-gpu-compositing");
expect(softwareScreenshot).not.toContain("--disable-gpu-compositing");
expect(hardwareBeginFrame).not.toContain("--disable-gpu-compositing");
});
it("uses Metal-backed ANGLE for hardware browser GPU mode on macOS", () => {
const args = buildChromeArgs({ ...base, platform: "darwin" }, { browserGpuMode: "hardware" });
expect(args).toContain("--enable-unsafe-webgpu");
@@ -686,6 +686,18 @@ export function buildChromeArgs(
// BeginFrame flags — only when using chrome-headless-shell on Linux
if (options.captureMode !== "screenshot") {
// SwiftShader's GPU compositor can retain a transformed layer for several
// sequential frames after a GSAP yoyo/reversal. The DOM and timeline are
// already at the requested time, but both BeginFrame and
// Page.captureScreenshot read the stale surface (the duplicate is present
// in the raw JPEG before encoding). Keep deterministic BeginFrame capture,
// but route compositing through Chrome's software path when the browser is
// already in software-GPU mode. Hardware-GPU and screenshot captures keep
// their existing compositor paths. Remove this workaround once the pinned
// chrome-headless-shell includes https://issues.chromium.org/issues/535256667.
if (browserGpuMode === "software") {
chromeArgs.push("--disable-gpu-compositing");
}
chromeArgs.push(
"--deterministic-mode",
"--enable-begin-frame-control",