Skip to content

Commit

Permalink
chore: try workaround for webgl rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Jan 18, 2024
1 parent 29eae32 commit 7a4ef48
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/utils/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ async function openInPage(page, target, lang, timezone, cookies, viewport, anima
}
}

// replace all canvas with img to make sure we capture them
// cf /~https://github.com/puppeteer/puppeteer/issues/1731#issuecomment-864345938
let canvases = await page.$$('canvas')
for (let canvas of canvases) {
let str = await canvas.screenshot({ encoding: 'base64' })
let dataUrl = 'data:image/png;base64,' + str
await canvas.evaluate((canvas, dataUrl) => {
const newDiv = document.createElement('div')
newDiv.innerHTML = '<img src="' + dataUrl + '">'
canvas.parentNode.replaceChild(newDiv, canvas)
}, dataUrl)
}

return { page, animationActivated }
}

Expand Down

0 comments on commit 7a4ef48

Please sign in to comment.