mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* fix(cli): snapshot, check, layout and thumbnails honour software WebGPU like render * test(cli): stub the local WebGPU helper in the studio server tests * fix(engine): webgpu compositions are recognised after the bundled runtime script * fix(engine): a hung GPU probe falls back to software in 15 s instead of 120 s * fix(engine): the GPU probe keeps the configured launch timeout and bounds only its page * build(parsers): declare the html-attribute-spans subpath in its descriptor * build(gcp-cloud-run): the BeginFrame contract stage copies parsers, which the engine now imports * test(cli): the screenshot launch pin follows the shared local WebGPU helper * fix(engine): the GPU probe's wait for Chrome's first page falls inside its 15 s limit
44 lines
2.1 KiB
TypeScript
44 lines
2.1 KiB
TypeScript
import { buildChromeArgs } from "@hyperframes/engine";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { resolveLocalBrowserGpuMode, resolveLocalWebGpu } from "./gpuPolicy.js";
|
|
|
|
// compositionRequiresWebGpu and assertWebGpuAdapterAvailable are implemented
|
|
// in @hyperframes/engine (browserManager.ts) and only re-exported here — see
|
|
// that package's browserManager.test.ts for their coverage.
|
|
describe("local browser GPU policy", () => {
|
|
it("defaults to auto and preserves explicit CLI/env overrides", () => {
|
|
expect(resolveLocalBrowserGpuMode(undefined, undefined)).toBe("auto");
|
|
expect(resolveLocalBrowserGpuMode(undefined, "hardware")).toBe("hardware");
|
|
expect(resolveLocalBrowserGpuMode(undefined, "software")).toBe("software");
|
|
expect(resolveLocalBrowserGpuMode(true, "software")).toBe("hardware");
|
|
expect(resolveLocalBrowserGpuMode(false, "hardware")).toBe("software");
|
|
});
|
|
});
|
|
|
|
describe("resolveLocalWebGpu", () => {
|
|
afterEach(() => vi.unstubAllEnvs());
|
|
const launchArgs = (gpuConfig: ReturnType<typeof resolveLocalWebGpu>["gpuConfig"]) =>
|
|
buildChromeArgs(
|
|
{ width: 640, height: 360, captureMode: "screenshot", requiresWebGpu: true },
|
|
gpuConfig,
|
|
);
|
|
|
|
it("runs a WebGPU composition on SwiftShader in software mode when render's opt-in is set", () => {
|
|
vi.stubEnv("PRODUCER_ALLOW_SOFTWARE_WEBGPU", "true");
|
|
const { gpuConfig, softwareWebGpu } = resolveLocalWebGpu("software", true);
|
|
expect(softwareWebGpu).toBe(true);
|
|
expect(launchArgs(gpuConfig)).toContain("--use-vulkan=swiftshader");
|
|
});
|
|
|
|
it("stays off without the opt-in, on a GPU, or for a composition that does not need WebGPU", () => {
|
|
vi.stubEnv("PRODUCER_ALLOW_SOFTWARE_WEBGPU", "");
|
|
expect(resolveLocalWebGpu("software", true).softwareWebGpu).toBe(false);
|
|
expect(launchArgs(resolveLocalWebGpu("software", true).gpuConfig)).not.toContain(
|
|
"--use-vulkan=swiftshader",
|
|
);
|
|
vi.stubEnv("PRODUCER_ALLOW_SOFTWARE_WEBGPU", "true");
|
|
expect(resolveLocalWebGpu("hardware", true).softwareWebGpu).toBe(false);
|
|
expect(resolveLocalWebGpu("software", false).softwareWebGpu).toBe(false);
|
|
});
|
|
});
|