angular-feedback icon indicating copy to clipboard operation
angular-feedback copied to clipboard

Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases

Open codebymikey opened this issue 9 years ago • 1 comments

Currently running into this issue when trying to send feedback:

Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
     onrendered @ angular-send-feedback.js:487
     options.complete @ html2canvas.js:2711
     start @ html2canvas.js:2215
     img.onload @ html2canvas.js:2352

Any insight to why this might be happening would be extremely helpful.

codebymikey avatar Jul 06 '16 10:07 codebymikey

This appears to be related to Google maps and it not sending CORS headers with its images. https://github.com/niklasvh/html2canvas/issues/485

Since the error occurs on this line: img = _canvas.get(0).toDataURL(); I propose adding a beforeScreenshotTaken callback before making this call so that the user can do any clean up, e.g. hide the map etc., the new code block will look similar to this:

_ctx = _canvas.get(0).getContext('2d');
settings.beforeScreenshotTaken(_ctx , _canvas);
 _ctx.drawImage(canvas, 0, sy, w, dh, 0, 0, w, dh);
img = _canvas.get(0).toDataURL();
$(document).scrollTop(sy);
post.img = img;
settings.onScreenshotTaken(post.img);

codebymikey avatar Jul 06 '16 10:07 codebymikey