Maximum height 16,384 pixels for headless Chrome screenshots?

No matter what I try, the maximum height of a full-page screenshot with headless Chrome 60 (and 59) is 16.348px.

This is not a memory problem. There are no segfaults and no messages, for example FATAL:memory_linux.cc(35) Out of memory.

. No one. Capture screenshots "successful". Changing the screenshot format - PNG or JPEG - has no effect.

The screen width can vary, but the height of the saved screenshot is always limited to 16,348px. Example,

1600x16384, 1200x16384, 2400x16384, etc.

I am taking screenshots with this minimal code ( full source ):

const upscale = 2;

const viewportWidth = 1200;
const viewportHeight = 800;

....

// Set up viewport resolution, etc.
const deviceMetrics = {
    width: viewportWidth,
    height: viewportHeight,
    deviceScaleFactor: 0,
    mobile: false,
    fitWindow: false,
    scale: 1    // Relative to the upscale
};
await Emulation.setDeviceMetricsOverride(deviceMetrics);
await Emulation.setVisibleSize({width: viewportWidth, height: viewportHeight});
await Emulation.setPageScaleFactor({pageScaleFactor: upscale});

// Navigate to target page
await Page.navigate({url});

const {root: {nodeId: documentNodeId}} = await DOM.getDocument();
const {nodeId: bodyNodeId} = await DOM.querySelector({
    selector: 'body',
    nodeId: documentNodeId,
});
const {model: {height}} = await DOM.getBoxModel({nodeId: bodyNodeId});

// Upscale the dimensions for full page
await Emulation.setVisibleSize({width: Math.round(viewportWidth * upscale), height: Math.round(height * upscale)});

// This forceViewport call ensures that content outside the viewport is
// rendered, otherwise it shows up as grey. Possibly a bug?
await Emulation.forceViewport({x: 0, y: 0, scale: upscale});

const screenshot = await Page.captureScreenshot({format});
const buffer = new Buffer(screenshot.data, 'base64');

file.writeFile(outFile, buffer, 'base64', function (err) {
    if (err) {
        console.error('Exception while saving screenshot:', err);
    } else {
        console.log('Screenshot saved');
    }
    client.close();
});

      

I couldn't find any useful Chrome switches . Is this Chrome's hard limit? 16384 is a suspicious number (2 ^ 14 = 16384). How to increase this height?

+3


source to share


1 answer


This is Chrome limitation as described in this bug



https://bugs.chromium.org/p/chromium/issues/detail?id=770769&desc=2

0


source







All Articles