html2canvas icon indicating copy to clipboard operation
html2canvas copied to clipboard

The performance problem with cloning document contains a lot of SVG nodes

Open ybaturin opened this issue 3 years ago • 3 comments

  • [o] You are using the latest version
  • [o] You are testing using the non-minified version of html2canvas and checked any potential issues reported in the console

Bug reports:

If a page contains a log of SVG nodes, e.g. amCharts (based on SVG), the call html2canvas(pageNode) freezes Firefox & Safari for a while. It could take several minutes. Just compare:

  • Render a big SVG chart takes ~ 15 seconds on my PC (https://jsfiddle.net/yaznayka/5axe04vt/33)
  • The same chart with turned "copyCssStyles" off (https://i.imgur.com/vDUhd3O.png) ~ 1 second (https://jsfiddle.net/yaznayka/5axe04vt/35)

Suggestion

Add an option in html2canvas to turn off copyCssStyles in SVG nodes.

Specifications:

  • html2canvas version tested with: 1.0.0-rc.7
  • Browser & version: Chrome Version 89.0.4389.90 (Official Build)
  • Operating system: Linux mint

ybaturin avatar Mar 22 '21 13:03 ybaturin

I have this same issue (of an SVG heavy chart taking 30+ seconds to render all while hanging the entire web site in safari), so... +1 on this being needed!

steven-wilson-crl avatar Jun 02 '21 20:06 steven-wilson-crl

Cloning the whole page to take a screenshot of a small part is an overkill IMHO. I'm wondering whether there is a way to not clone the whole page.

Finesse avatar Nov 08 '21 13:11 Finesse

@niklasvh It makes sense. Please, pay attention to this

BlueLamantine avatar Apr 14 '22 10:04 BlueLamantine