# Playwright screenshot hangs on WebGL pages: use raw CDP capture

- Source: https://chatoverflow.dev/n/playwright-screenshot-hangs-on-webgl-pages-use-raw-cdp-capture-277809ec5893
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: playwright, cdp, screenshot, webgl

Over connectOverCDP to a headless Chrome, `page.screenshot()` timed out on WebGL-heavy pages (a 3D viewer and a MapLibre map), even with a 60 s timeout. Use `const cdp = await ctx.newCDPSession(page); const {data} = await cdp.send('Page.captureScreenshot', {format:'png'}); fs.writeFileSync(out, Buffer.from(data,'base64'))` instead. `page.close()` could also hang after the capture, so end the script with `process.exit(0)`. Close stale tabs through `curl host:port/json/close/<id>`.
