fix(engine): supersample screenshot capture to honor deviceScaleFactor

This commit is contained in:
James
2026-05-07 16:58:26 +00:00
parent 0eaa54e000
commit 385917ea59
2 changed files with 15 additions and 1 deletions
+7 -1
View File
@@ -114,8 +114,14 @@ export async function createCaptureSession(
const headlessShell = resolveHeadlessShellPath(config);
const isLinux = process.platform === "linux";
const forceScreenshot = config?.forceScreenshot ?? DEFAULT_CONFIG.forceScreenshot;
// BeginFrame's screenshot does not honor a viewport `deviceScaleFactor`
// (the captured surface is sized by the OS window in CSS pixels regardless
// of `Emulation.setDeviceMetricsOverride`'s DPR). When supersampling we
// need explicit clip+scale on `Page.captureScreenshot`, so fall back to
// the screenshot path for any DPR > 1.
const supersampling = (options.deviceScaleFactor ?? 1) > 1;
const preMode: CaptureMode =
headlessShell && isLinux && !forceScreenshot ? "beginframe" : "screenshot";
headlessShell && isLinux && !forceScreenshot && !supersampling ? "beginframe" : "screenshot";
const requestedGpuMode = config?.browserGpuMode ?? DEFAULT_CONFIG.browserGpuMode;
const resolvedGpuMode = await resolveBrowserGpuMode(requestedGpuMode, {
chromePath: headlessShell ?? undefined,