I'm trying to take a screenshot of a website (in which I control) using puppeteer in headless mode.
The problem is, there is a WebGL canvas on my website that won't get rendered in a headless mode screenshot (but works in headful mode).
All I get in headless mode is a black PNG.
I've tried changing the WebGL context parameters to multiple combinations but nothing works.
I'm using puppeteer version 5.5.0 and chromium version 88.0.4298.0
Here is my puppeteer crawler code:
const puppeteer = require("puppeteer");
const url = "https://phcs93.github.io/genesis/";
async function crawl () {
const browser = await puppeteer.launch({
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--mute-audio'
]
});
const page = await browser.newPage();
await page.goto(url, {
"waitUntil": "networkidle0",
"timeout": 0
});
await page.screenshot({ path: "screenshot.png" });
await browser.close();
}
(async () => await crawl())();
And these are the current parameters I'm using on the WebGL context of my website:
const gl = canvas.getContext("webgl2", {
preserveDrawingBuffer: true,
alpha: false,
antialias: true,
premultipliedAlpha: true
});