Files
hyperframes/packages/cli/src/browser/gpuPolicy.ts
T
Miguel Ángel c96099d39a fix(cli): bound checks of non-finishing compositions (#5537)
* fix(cli): bound checks of non-finishing compositions

* fix(cli): account for cold startup in deadline witness

* fix(cli): wait for profile owners before test cleanup

* test(cli): separate portable deadline and Linux process witnesses

* test(cli): preserve per-launch browser profile ownership

* fix(cli): start check deadline after browser readiness
2026-10-13 13:49:05 +00:00

39 lines
1.7 KiB
TypeScript

import { resolveConfig, usesSoftwareWebGpu, type GpuProbeLifecycle } from "@hyperframes/engine";
export type BrowserGpuMode = "auto" | "hardware" | "software";
export type ResolvedBrowserGpuMode = Exclude<BrowserGpuMode, "auto">;
export function resolveLocalBrowserGpuMode(
browserGpuArg?: boolean,
envMode = process.env.PRODUCER_BROWSER_GPU_MODE,
): BrowserGpuMode {
if (browserGpuArg === true) return "hardware";
if (browserGpuArg === false) return "software";
if (envMode === "hardware" || envMode === "software" || envMode === "auto") return envMode;
return "auto";
}
export async function resolveCaptureBrowserGpuMode(
requestedMode: BrowserGpuMode,
chromePath?: string,
probeLifecycle?: GpuProbeLifecycle,
): Promise<ResolvedBrowserGpuMode> {
const { resolveBrowserGpuMode } = await import("@hyperframes/engine");
return resolveBrowserGpuMode(requestedMode, { chromePath, probeLifecycle });
}
// `compositionRequiresWebGpu` and the launch-time WebGPU guard now live in
// @hyperframes/engine (browserManager.ts) — the shared choke point every
// buildChromeArgs caller goes through, CLI included. Re-exported here so
// existing CLI imports don't need to change their module path.
export { compositionRequiresWebGpu, assertWebGpuAdapterAvailable } from "@hyperframes/engine";
/** The launch config and adapter check for a local capture, honouring PRODUCER_ALLOW_SOFTWARE_WEBGPU as render does. */
export function resolveLocalWebGpu(
browserGpuMode: ResolvedBrowserGpuMode,
requiresWebGpu: boolean,
) {
const gpuConfig = { browserGpuMode, allowSoftwareWebGpu: resolveConfig().allowSoftwareWebGpu };
return { gpuConfig, softwareWebGpu: usesSoftwareWebGpu(requiresWebGpu, gpuConfig) };
}