notebook.screenshot uses ElementHandle.screenshot under the hood, which is slow but necessary is many cases. But, if the cell that want's to be screenshot is already a canvas, then calling .toDataURL() and passing that base64 string back to node would be much faster, I think.
So new screenshot algo would be:
- Get the cell's element handle
- If it is a canvas element, then get the data url, pass back to node, then covert to buffer/write as a png/jpeg/whatever manually.
- Else use
ElementHandle.screenshot and suffer
To be sure, need to benchmark how fast .screenshot is currently, and how much faster .toDataURL() would be. Might as well throw .svg() and .html() benchmarking in here too to compare.
notebook.screenshotusesElementHandle.screenshotunder the hood, which is slow but necessary is many cases. But, if the cell that want's to be screenshot is already a canvas, then calling.toDataURL()and passing that base64 string back to node would be much faster, I think.So new screenshot algo would be:
ElementHandle.screenshotand sufferTo be sure, need to benchmark how fast
.screenshotis currently, and how much faster.toDataURL()would be. Might as well throw.svg()and.html()benchmarking in here too to compare.