niklasvh / html2canvas

Screenshots with JavaScript
https://html2canvas.hertzen.com/
MIT License
30.15k stars 4.75k forks source link

WkWebview Security Issue #2351

Open royparijat opened 3 years ago

royparijat commented 3 years ago

I took the latest non-minified version of html2canvas but I get a security exception in iOS WkWebview when I try canvas.toDataURL()

I also added a second parameter to the html2canvas init call as {useCORS:false} but the same issue persists. Let me know if there is a known fix that I am missing.

dragon-war commented 3 years ago

Facing the same issue, please suggest a workaround @niklasvh

stuart-leftisright commented 3 years ago

Was also able to replicate canvas.toDataURL() errors on latest version & iOS. Have seen a much older version of library and common counterparts (jsPDF/html2pdf.js) work fine on latest iOS. Unsure as to reasons for this difference

stuart-leftisright commented 3 years ago

@royparijat @dragon-war Just wondering if you found any workarounds since September? Thank you

Edit: I was able to resolve the issue simply by removing or swapping an image that was part of the screengrab. Therefore its presumably to do with encoding / metadata of the image file. I've seen Xcode reject images in the past for similar reasons and had to 'clean' the image of its extra data. Apologies for not being more specific with terminology or details

tonlen commented 3 years ago

Solution:Setting “Disable web security” and “allow file access from files” in iOS WKWebView