fix(engine): GPU probe, HDR capture and host-ceiling probe keep a required sandbox (#8018)

* fix(engine): GPU probe, HDR capture and host-ceiling probe keep a required sandbox

These three launches always passed --no-sandbox, even where HYPERFRAMES_CHROME_SANDBOX=1
says Chrome must keep its sandbox. They now drop it in that case and behave as before
otherwise.

— Rames

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(engine): HDR capture passes --no-zygote only alongside --no-sandbox

Chrome exits at launch ("Zygote cannot be disabled if sandbox is enabled") when
--no-zygote is passed with its sandbox on, so HDR capture under
HYPERFRAMES_CHROME_SANDBOX=1 needs to drop it together with --no-sandbox.

— Rames

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
James Russo
2026-11-17 04:12:56 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent e58fb3249b
commit fb5f9e52ce
5 changed files with 45 additions and 7 deletions
@@ -41,7 +41,11 @@ import {
} from "./publicNetwork/captureProxy.js";
import { removeTreeBestEffortAsync } from "@hyperframes/core/remove-tree";
import { getSystemTotalMb, LOW_MEMORY_TOTAL_MB_THRESHOLD } from "./systemMemory.js";
import { chromeSandboxArgs, launchWithChromeSandboxFallback } from "./chromeSandbox.js";
import {
chromeSandboxArgs,
launchWithChromeSandboxFallback,
noSandboxUnlessRequired,
} from "./chromeSandbox.js";
import { describeWslGpuAccess, detectWsl, type WslHostFacts } from "./wslHost.js";
import {
BrowserLeasePool,
@@ -572,8 +576,7 @@ async function getPuppeteerOrNull(): Promise<PuppeteerNode | null> {
function getHardwareGpuProbeArgs(platform: NodeJS.Platform): string[] {
return [
"--no-sandbox",
"--disable-setuid-sandbox",
...noSandboxUnlessRequired(),
"--disable-dev-shm-usage",
"--enable-webgl",
"--ignore-gpu-blocklist",
@@ -5,6 +5,7 @@ import { debuglog } from "node:util";
import { release } from "node:os";
import { dirname, join } from "node:path";
import { buildChromeLaunchEnv } from "@hyperframes/core/chrome-env";
import { noSandboxUnlessRequired } from "./chromeSandbox.js";
/** Chrome 151 dropped macOS 12 and older (Darwin < 22); 150 is the last major that launches there. */
const MACOS_12_LAST_CHROME_MAJOR = 150;
@@ -159,7 +160,7 @@ const debug = debuglog("hyperframes:browser");
export function shellStarts(binary: string, timeoutMs = 10_000): boolean {
let answer = starts.get(binary);
if (answer === undefined) {
const probe = ["--no-sandbox", "--dump-dom", "about:blank"];
const probe = [...noSandboxUnlessRequired(), "--dump-dom", "about:blank"];
answer =
spawnSync(binary, probe, {
env: buildChromeLaunchEnv(),
@@ -4,9 +4,11 @@ import {
chromeSandboxEnabled,
launchWithChromeSandboxFallback,
NO_SANDBOX_ARGS,
noSandboxUnlessRequired,
type ChromeSandboxHost,
} from "./chromeSandbox.js";
import { buildChromeArgs } from "./browserManager.js";
import { buildHdrChromeArgs } from "./hdrCapture.js";
function host(overrides: Partial<ChromeSandboxHost> = {}): ChromeSandboxHost {
return {
@@ -70,6 +72,32 @@ describe("chromeSandboxEnabled", () => {
});
});
describe("launches that always ran without the sandbox", () => {
it("keep it when HYPERFRAMES_CHROME_SANDBOX=1 requires it, and run as before otherwise", () => {
expect(noSandboxUnlessRequired({ HYPERFRAMES_CHROME_SANDBOX: "1" })).toEqual([]);
expect(noSandboxUnlessRequired({})).toEqual(["--no-sandbox", "--disable-setuid-sandbox"]);
});
it("HDR capture keeps the sandbox when it is required, and drops --no-zygote with it", () => {
vi.stubEnv("HYPERFRAMES_CHROME_SANDBOX", "1");
try {
const args = buildHdrChromeArgs(640, 360);
expect(args).not.toContain("--no-sandbox");
expect(args).not.toContain("--no-zygote");
} finally {
vi.unstubAllEnvs();
}
vi.stubEnv("HYPERFRAMES_CHROME_SANDBOX", "");
try {
expect(buildHdrChromeArgs(640, 360)).toEqual(
expect.arrayContaining(["--no-sandbox", "--disable-setuid-sandbox", "--no-zygote"]),
);
} finally {
vi.unstubAllEnvs();
}
});
});
describe("buildChromeArgs sandbox flags", () => {
const base = { width: 320, height: 240, platform: "linux" as const };
@@ -58,6 +58,10 @@ export function chromeSandboxEnabled(host: ChromeSandboxHost = currentHost()): b
return host.platform !== "linux" || !linuxCannotSandbox(host);
}
export function noSandboxUnlessRequired(env: NodeJS.ProcessEnv = process.env): string[] {
return env.HYPERFRAMES_CHROME_SANDBOX === "1" ? [] : ["--no-sandbox", "--disable-setuid-sandbox"];
}
export function chromeSandboxArgs(sandbox = chromeSandboxEnabled()): string[] {
return sandbox ? [] : NO_SANDBOX_ARGS;
}
+5 -3
View File
@@ -23,6 +23,7 @@ import { withHyperframesBrowserMarker } from "@hyperframes/core/browser-marker";
import { buildChromeLaunchEnv } from "@hyperframes/core/chrome-env";
import type { Page, Browser, PuppeteerNode } from "puppeteer-core";
import { resolveFullChromePath, ownedLaunchOptions } from "./browserManager.js";
import { noSandboxUnlessRequired } from "./chromeSandbox.js";
// ── PQ (SMPTE 2084) OETF ─────────────────────────────────────────────────────
@@ -262,10 +263,11 @@ export async function launchHdrBrowser(
}
export function buildHdrChromeArgs(width: number, height: number): string[] {
const noSandbox = noSandboxUnlessRequired();
const noZygoteOnlyWithoutSandbox = noSandbox.length > 0 ? ["--no-zygote"] : [];
return [
"--enable-unsafe-webgpu",
"--no-sandbox",
"--disable-setuid-sandbox",
...noSandbox,
"--window-position=-10000,-10000",
`--window-size=${width},${height}`,
"--disable-background-timer-throttling",
@@ -276,7 +278,7 @@ export function buildHdrChromeArgs(width: number, height: number): string[] {
"--disable-component-update",
"--disable-default-apps",
"--disable-sync",
"--no-zygote",
...noZygoteOnlyWithoutSandbox,
"--force-gpu-mem-available-mb=4096",
"--autoplay-policy=no-user-gesture-required",
];