Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes image is not output in Safari #2424

Closed
sasanquaneuf opened this issue Nov 23, 2020 · 1 comment
Closed

Sometimes image is not output in Safari #2424

sasanquaneuf opened this issue Nov 23, 2020 · 1 comment

Comments

@sasanquaneuf
Copy link

  • [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:

Safari (iOS/Mac) fail to write image to canvas sometimes. The structure of html-element is following (simplified):

<div class="render-root">
  <img src="somefile.png" />
</div>

and pass the render-root div to html2canvas.
The image is already loaded and displayed, but the canvas didn't contain the image sometimes. I tried one hundred, and nearly eighty are succeed, bu other twenty there is no image in canvas.
I investigated this. In canvas-renderer.ts, renderReplacedElement() function has the input check image && container.intrinsicWidth > 0 && container.intrinsicHeight > 0, sometimes container.intrinsicWidth and container.intrinsicHeight are 0.

Specifications:

  • html2canvas version tested with: 1.0.0-rc.7
  • Browser & version: Safari 13.1(iOS), 13.1.1(Mac)
  • Operating system: iOS/Mac

Note:

When I re-called html2canvas, then the phenomenon was disappeared. So, when container.intrinsicWidth === 0 || container.intrinsicHeight === 0 I hope to reject the result promise.
For this purpose, I'll create pull-request that add option for reject image loading error (contains width/height are zero).

@niklasvh
Copy link
Owner

niklasvh commented Aug 5, 2021

Should be fixed with #2577

@niklasvh niklasvh closed this as completed Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants