asg017/observable-prerender

"Screenshot" canvas cells faster

Opened this issue · 0 comments

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:

  1. Get the cell's element handle
  2. 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.
  3. 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.