mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-01 19:42:03 +00:00
fix(engine): warn once per process about unverified hardware GPU
This commit is contained in:
@@ -261,6 +261,11 @@ describe("resolveBrowserGpuMode", () => {
|
||||
const warning = warn.mock.calls.map((call) => String(call[0])).join("\n");
|
||||
expect(warning).toContain("browserGpuMode=hardware was requested");
|
||||
expect(warning).toContain("--gpus all");
|
||||
// Once per process, not once per worker — the render path resolves the
|
||||
// mode for the probe browser plus every parallel worker.
|
||||
await resolveBrowserGpuMode("hardware", { platform: "linux" });
|
||||
await resolveBrowserGpuMode("hardware", { platform: "linux" });
|
||||
expect(warn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("stays quiet when explicit 'hardware' probes to hardware", async () => {
|
||||
|
||||
@@ -438,6 +438,7 @@ let _autoBrowserGpuModeCache: Promise<"software" | "hardware"> | undefined;
|
||||
/** Test-only: reset the cached probe result. */
|
||||
export function _resetAutoBrowserGpuModeCacheForTests(): void {
|
||||
_autoBrowserGpuModeCache = undefined;
|
||||
_unverifiedHardwareGpuWarned = false;
|
||||
}
|
||||
|
||||
async function getPuppeteerOrNull(): Promise<PuppeteerNode | null> {
|
||||
@@ -544,13 +545,20 @@ export function resolveBrowserGpuMode(
|
||||
if (mode === "auto") return _autoBrowserGpuModeCache;
|
||||
|
||||
return _autoBrowserGpuModeCache.then((probed) => {
|
||||
if (probed === "software") {
|
||||
// Warn once per process, not once per caller: `createCaptureSession`
|
||||
// resolves the mode for the probe browser AND every parallel worker, so
|
||||
// an un-deduplicated warning prints N+1 times and buries itself.
|
||||
if (probed === "software" && !_unverifiedHardwareGpuWarned) {
|
||||
_unverifiedHardwareGpuWarned = true;
|
||||
console.warn(buildUnverifiedHardwareGpuWarning(options.platform ?? process.platform));
|
||||
}
|
||||
return "hardware";
|
||||
});
|
||||
}
|
||||
|
||||
/** One-shot latch for the explicit-hardware-probed-to-software warning. */
|
||||
let _unverifiedHardwareGpuWarned = false;
|
||||
|
||||
/**
|
||||
* Warning text for "you asked for hardware GPU, the probe found none".
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user