mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-12 07:09:59 +00:00
fix(engine): restore fast screenshot path for viewport captures (#1670)
This commit is contained in:
@@ -135,11 +135,10 @@ export async function pageScreenshotCapture(page: Page, options: CaptureOptions)
|
||||
format: isPng ? "png" : "jpeg",
|
||||
quality: isPng ? undefined : (options.quality ?? 80),
|
||||
fromSurface: true,
|
||||
// The explicit clip rect constrains output to exact composition
|
||||
// dimensions. The viewport-boundary pre-clip from captureBeyondViewport:
|
||||
// false is redundant, and Chrome's compositor rounds it inward under
|
||||
// multi-tab load — clipping the bottom/right edge of tall viewports.
|
||||
captureBeyondViewport: true,
|
||||
// Use Chrome's faster viewport-bound screenshot path by default. Callers
|
||||
// opt into the beyond-viewport path only for known compositor edge cases,
|
||||
// such as native video surfaces in tall portrait renders.
|
||||
captureBeyondViewport: options.captureBeyondViewport ?? false,
|
||||
optimizeForSpeed: !isPng,
|
||||
clip,
|
||||
});
|
||||
@@ -172,7 +171,8 @@ export async function captureScreenshotWithAlpha(
|
||||
const result = await client.send("Page.captureScreenshot", {
|
||||
format: "png",
|
||||
fromSurface: true,
|
||||
captureBeyondViewport: true, // see pageScreenshotCapture for rationale
|
||||
// Preserve the #1094 tall-portrait edge-clipping guard on HDR alpha captures.
|
||||
captureBeyondViewport: true,
|
||||
optimizeForSpeed: false, // `true` uses a zero-alpha-aware fast path that crushes real alpha values — observed empirically, CDP docs don't spell it out
|
||||
clip: { x: 0, y: 0, width, height, scale: 1 },
|
||||
});
|
||||
@@ -237,7 +237,8 @@ export async function captureAlphaPng(page: Page, width: number, height: number)
|
||||
const result = await client.send("Page.captureScreenshot", {
|
||||
format: "png",
|
||||
fromSurface: true,
|
||||
captureBeyondViewport: true, // see pageScreenshotCapture for rationale
|
||||
// Preserve the #1094 tall-portrait edge-clipping guard on HDR alpha captures.
|
||||
captureBeyondViewport: true,
|
||||
optimizeForSpeed: false, // must be false to preserve alpha
|
||||
clip: { x: 0, y: 0, width, height, scale: 1 },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user