Skip to content

Write HTML. Render video. Built for agents.

fix(cli): capture works inside an agent's macOS sandbox (#5840)

Miguel Ángeldc0e80e73af1
diff --git a/packages/cli/src/browser/launch.noListen.test.ts b/packages/cli/src/browser/launch.noListen.test.ts
index 6086fda57d..f40dd4f2fa 100644
--- a/packages/cli/src/browser/launch.noListen.test.ts
+++ b/packages/cli/src/browser/launch.noListen.test.ts
@@ -30,7 +30,7 @@ describe("the GPU probe where nothing may listen", () => {
await resolveManagedGpuMode("auto", "/chrome");
expect(probe.options[0]).toMatchObject({
pipe: true,
- args: ["--headless", "--single-process"],
+ args: ["--headless", "--single-process", "--disable-gpu-compositing"],
});
expect(probe.options[1]!.pipe).toBeUndefined();
expect(probe.options[1]!.args).toEqual(["--headless"]);
diff --git a/packages/cli/src/browser/sandboxDenied.test.ts b/packages/cli/src/browser/sandboxDenied.test.ts
index f609d12867..bf3f22bb1f 100644
--- a/packages/cli/src/browser/sandboxDenied.test.ts
+++ b/packages/cli/src/browser/sandboxDenied.test.ts
@@ -58,7 +58,10 @@ describe("a browser inside an agent's macOS seatbelt", () => {
const { puppeteer, launches } = recordingPuppeteer([]);
await launchManagedBrowser(puppeteer, { args: ["--headless"] });
expect(launches).toHaveLength(1);
- expect(launches[0]).toMatchObject({ pipe: true, args: ["--headless", "--single-process"] });
+ expect(launches[0]).toMatchObject({
+ pipe: true,
+ args: ["--headless", "--single-process", "--disable-gpu-compositing"],
+ });
});
it("relaunches as one process over a pipe when an unnamed sandbox refuses the mach service", async () => {
@@ -66,7 +69,11 @@ describe("a browser inside an agent's macOS seatbelt", () => {
const { puppeteer, launches } = recordingPuppeteer([SEATBELT_LAUNCH_FAILURE]);
await expect(launchManagedBrowser(puppeteer, { args: ["--headless"] })).resolves.toBeDefined();
expect(launches.map((options) => options.pipe ?? false)).toEqual([false, true]);
- expect(launches[1]!.args).toEqual(["--headless", "--single-process"]);
+ expect(launches[1]!.args).toEqual([
+ "--headless",
+ "--single-process",
+ "--disable-gpu-compositing",
+ ]);
});
});
diff --git a/packages/cli/src/browser/sandboxDenied.ts b/packages/cli/src/browser/sandboxDenied.ts
index 2268846be2..ec629f9b9c 100644
--- a/packages/cli/src/browser/sandboxDenied.ts
+++ b/packages/cli/src/browser/sandboxDenied.ts
@@ -2,6 +2,7 @@ import type { LaunchOptions } from "puppeteer-core";
const MACH_SERVICE_DENIED = /bootstrap_check_in\b[^\n]*Permission denied/;
const SINGLE_PROCESS = "--single-process";
+const CPU_COMPOSITING = "--disable-gpu-compositing";
export function machServiceDenied(errorMessage: string): boolean {
return MACH_SERVICE_DENIED.test(errorMessage);
@@ -12,14 +13,11 @@ export function inAgentSandbox(env = process.env, platform = process.platform):
return platform === "darwin" && env.CODEX_SANDBOX === "seatbelt";
}
-/** The one launch a seatbelt allows: no child process can register its mach port and nothing may listen. */
+/** The one launch a seatbelt allows: no child process registers a mach port, nothing listens, no GPU composites. */
export function oneProcessOverPipe(options: LaunchOptions): LaunchOptions {
const args = options.args ?? [];
- return {
- ...options,
- pipe: true,
- args: args.includes(SINGLE_PROCESS) ? args : [...args, SINGLE_PROCESS],
- };
+ const missing = [SINGLE_PROCESS, CPU_COMPOSITING].filter((flag) => !args.includes(flag));
+ return { ...options, pipe: true, args: [...args, ...missing] };
}
export function isOneProcessOverPipe(options: LaunchOptions): boolean {
diff --git a/packages/cli/src/capture/captureCompositionFrame.browserFallback.test.ts b/packages/cli/src/capture/captureCompositionFrame.browserFallback.test.ts
index 0639649ff5..624f95cf2b 100644
--- a/packages/cli/src/capture/captureCompositionFrame.browserFallback.test.ts
+++ b/packages/cli/src/capture/captureCompositionFrame.browserFallback.test.ts
@@ -221,7 +221,11 @@ describe("openSettledCompositionPage when nothing may listen", () => {
await openSettledCompositionPage(HTML, server.url, OPTIONS);
expect(launched().pipe).toBe(true);
- expect(launched().args).toEqual(["--headless", "--single-process"]);
+ expect(launched().args).toEqual([
+ "--headless",
+ "--single-process",
+ "--disable-gpu-compositing",
+ ]);
expect(opened.page.setRequestInterception).toHaveBeenCalledWith(true);
const onRequest = opened.page.on.mock.calls.find(([event]) => event === "request")![1];
const respond = vi.fn(async (_response: { status: number; body: Buffer }) => undefined);