mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-15 13:58:20 +00:00
Cherry-picked from feat/html-in-canvas-launch (PR #611): - Enable --enable-features=CanvasDrawElement in Chrome browser args so HTML-in-canvas compositions render correctly - Add native drawElementImage() capture path for shader transitions with existing fallback preserved - Reuse renderer Chrome args in hyperframes validate for consistent WebGL/CanvasDrawElement environment - Add capture.test.ts for the new shader transition capture path
80 lines
2.9 KiB
TypeScript
80 lines
2.9 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { buildChromeArgs, forceReleaseBrowser } from "./browserManager.js";
|
|
|
|
describe("buildChromeArgs browser GPU mode", () => {
|
|
const base = { width: 1920, height: 1080 };
|
|
|
|
it("uses SwiftShader software GL by default for reproducible local renders", () => {
|
|
const args = buildChromeArgs(base);
|
|
expect(args).toContain("--enable-features=CanvasDrawElement");
|
|
expect(args).toContain("--use-gl=angle");
|
|
expect(args).toContain("--use-angle=swiftshader");
|
|
expect(args).not.toContain("--enable-gpu-rasterization");
|
|
});
|
|
|
|
it("uses Metal-backed ANGLE for hardware browser GPU mode on macOS", () => {
|
|
const args = buildChromeArgs({ ...base, platform: "darwin" }, { browserGpuMode: "hardware" });
|
|
expect(args).toContain("--use-gl=angle");
|
|
expect(args).toContain("--use-angle=metal");
|
|
expect(args).toContain("--enable-gpu-rasterization");
|
|
expect(args).not.toContain("--use-angle=swiftshader");
|
|
});
|
|
|
|
it("uses D3D11-backed ANGLE for hardware browser GPU mode on Windows", () => {
|
|
const args = buildChromeArgs({ ...base, platform: "win32" }, { browserGpuMode: "hardware" });
|
|
expect(args).toContain("--use-gl=angle");
|
|
expect(args).toContain("--use-angle=d3d11");
|
|
expect(args).toContain("--enable-gpu-rasterization");
|
|
expect(args).not.toContain("--use-angle=swiftshader");
|
|
});
|
|
|
|
it("uses EGL for hardware browser GPU mode on Linux", () => {
|
|
const args = buildChromeArgs({ ...base, platform: "linux" }, { browserGpuMode: "hardware" });
|
|
expect(args).toContain("--use-gl=egl");
|
|
expect(args).toContain("--enable-gpu-rasterization");
|
|
expect(args).not.toContain("--use-gl=angle");
|
|
expect(args).not.toContain("--use-angle=swiftshader");
|
|
});
|
|
|
|
it("keeps --disable-gpu authoritative when requested", () => {
|
|
const args = buildChromeArgs(
|
|
{ ...base, platform: "darwin" },
|
|
{ browserGpuMode: "hardware", disableGpu: true },
|
|
);
|
|
expect(args).toContain("--disable-gpu");
|
|
expect(args).toContain("--use-angle=swiftshader");
|
|
expect(args).not.toContain("--use-angle=metal");
|
|
});
|
|
});
|
|
|
|
describe("forceReleaseBrowser", () => {
|
|
it("kills the browser process and disconnects", () => {
|
|
const killFn = vi.fn(() => true);
|
|
const disconnectFn = vi.fn();
|
|
const mockBrowser = {
|
|
process: () => ({ kill: killFn, killed: false }),
|
|
disconnect: disconnectFn,
|
|
} as any;
|
|
|
|
forceReleaseBrowser(mockBrowser);
|
|
|
|
expect(killFn).toHaveBeenCalledWith("SIGKILL");
|
|
expect(disconnectFn).toHaveBeenCalled();
|
|
});
|
|
|
|
it("tolerates an already-killed process", () => {
|
|
const killFn = vi.fn();
|
|
const disconnectFn = vi.fn();
|
|
const mockBrowser = {
|
|
process: () => ({ kill: killFn, killed: true }),
|
|
disconnect: disconnectFn,
|
|
} as any;
|
|
|
|
forceReleaseBrowser(mockBrowser);
|
|
|
|
expect(killFn).not.toHaveBeenCalled();
|
|
expect(disconnectFn).toHaveBeenCalled();
|
|
});
|
|
});
|