niklasvh / html2canvas

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

Error: Canvas area exceeds the maximum limit (width * height > 268435456) #3169

Open q2apro opened 5 months ago

q2apro commented 5 months ago

Bug:

Image is not created in Safari if the element is huge. Browsers Chrome and Edge work, however.

Error in the Safari console is: "Canvas area exceeds the maximum limit (width * height > 268435456)"

I tried to use the scale option but it seems to have no effect. I assume the code tries to create the canvas - and scales only afterwards. So the error persists.

image

How to fix this?


Update 1: I checked the image dimensions. It is 21504025 pixels area, so the 268435456 have not been exceeded.

image

Update 2:

I just learned that Safari has a maximum area limit of ONLY 5242880 pixels. See here: https://stackoverflow.com/a/23391599/1066234

Chrome: Maximum area: 268,435,456 pixels Firefox: Maximum area: 472,907,776 pixels

⚠️ Safari: ONLY 5,242,880 pixels