mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-04 16:42:27 +00:00
fix(renderer): prevent stale SwiftShader layers
This commit is contained in:
@@ -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,17 @@ 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.
|
||||
if (browserGpuMode === "software") {
|
||||
chromeArgs.push("--disable-gpu-compositing");
|
||||
}
|
||||
chromeArgs.push(
|
||||
"--deterministic-mode",
|
||||
"--enable-begin-frame-control",
|
||||
|
||||
Reference in New Issue
Block a user