tsayen / dom-to-image

Generates an image from a DOM node using HTML5 canvas
Other
10.28k stars 1.68k forks source link

Chrome 72+ throws an error while trying to generate image from one simple word #267

Closed pudek357 closed 11 months ago

pudek357 commented 5 years ago

Use case: description, code

codesandbox

Expected behavior

It should generate base64 image, it works in browsers listed below:

Same error occurs with all methods: toPng, toJpeg, toSvg.

Actual behavior (stack traces, console logs etc)

Chrome (72+) throws an error:


DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
    at eval


This error leads as to line: 
https://github.com/tsayen/dom-to-image/blob/master/src/dom-to-image.js#L110

Library version

2.6.0

Browsers

mfix22 commented 5 years ago

@tsayen we rely heavily on this library for https://carbon.now.sh, and it seems that Chrome 72+ is beginning to have tainted canvas issues. Would you be able to release a fix for this issue? Or is there another person who would be able to push a release?

FYI, this may however be a Chrome v72 bug (https://bugs.chromium.org/p/chromium/issues/detail?id=918460&q=tainted%20canvas&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified)

Adondriel commented 5 years ago

The ticket on chromium has been updated to the fixed status on January 10th.

forever0714yuan commented 11 months ago

你好,我已收到你的来信。辛苦了!!