无头Chrome浏览器屏幕截图的最大高度为16,384px?

无论我尝试什么,无头Chrome 60(和59)的全屏截图的最大高度是16,348px。

这不是一个记忆问题。 没有段错误,没有,例如, FATAL:memory_linux.cc(35) Out of memory. 消息。 没有。 捕捉屏幕截图是“成功的”。 更改屏幕截图格式 – PNG或JPEG – 没有任何影响。

屏幕截图的宽度可能会有所不同,但保存的屏幕截图的高度始终限制为16,348像素。 例,

1600×16384,1200×16384,2400×16384等

我正在使用这个最小的代码( 完整的源代码 )升级屏幕截图:

 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(); }); 

我无法find任何有用的Chrome开关 。 这是Chrome的硬编码限制吗? 16384是一个可疑的数字(2 ^ 14 = 16384)。 这个高度怎么会增加?