-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Canvas elements unrelated to the image conversion process are "tainted" with 2d drawing contexts #2805
Comments
I can't tell from the documentation whether it's preventable by some configuration option, but the code that clones a |
How would it determine what context type it should be getting for a |
In my case, the canvas elements are always used for webgl contexts, so I just made an initialization function that finds them all, and (unless marked with a class indicating that they're not webgl) it gets a webgl context. In general, however, I agree that it's impossible for code like Note that aside from this "bug", the code that attempts to clone the canvas elements seems to always try to get a webgl context after successfully getting a 2d context. As far as I know, that will never work, because once a context of a particular type has been gotten for a particular canvas element, no other type can be gotten. |
The logic presumes the page has gotten a context prior to html2canvas attempting to get one. So if the page is using it for 2d, html2canvas will succesfully get a 2d context, and if it was webgl, it will successfully get that instead. At the moment there isn't any configuration options available to alter that logic |
Testing with 1.4.0
Bug reports:
Calling
html2canvas
on an element in the DOM results in unrelated<canvas>
elements (everywhere in the DOM, as far as I can tell) being "contaminated" with a 2d drawing context, thus disallowing them from getting a webgl context later.https://jsfiddle.net/Pointy/Lxkj43no/
The fiddle reproduces the problem by first attempting to get a webgl context on one
<canvas>
unrelated to the image conversion, and it works. Then,html2canvas()
is invoked to convert an element. After that, the other unrelated<canvas>
on the page cannot be used to get a webgl drawing context.I'm not sure but I think it happens in the document cloning phase, but that's a big guess on my part.
Specifications:
The text was updated successfully, but these errors were encountered: