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
Calling html2canvas multiple times increases memory usage on Chrome #1609
Comments
me too, wait fix... |
I use vue-cli3, calling html2canvas multiple times increases memory usage, and fail to compile my project. |
I am having the same problem. The nodes are all detached but aren't being garbage collected. |
Thanks for the suggestion @ThunderWorm, but unfortunately this did not fix the problem for me. |
This seems to be fixed in the last version (1.0.0-rc3). |
This bug still happen in the last version (1.0.0-rc5). Please fixed this. |
Any good news here? I got the problem too. |
I recommend this one: https://github.com/bubkoo/html-to-image. It is very easy to use. The multiple screenshot function can be realized without memory leak. |
it was way worse for my use case it froze the app entirely |
Any progress with that? |
Hello, has the problem been solved? |
I used merge-images lib instead, it worked for me, the memory doesn't overflow anymore. When inserting text data into the image I use the text-to-image library (version 2.4.4), to rotate image I used base64-rotate. |
try this: html2canvas(dom,{removeContainer:false}).then(function(canvas) {
document.querySelectorAll('.html2canvas-container').forEach(el => {
const iframe = el.contentWindow;
if (el) {
el.src = 'about:blank';
iframe.document.write('');
iframe.document.clear();
iframe.close();
el.remove();
}
})
canvas.toBlob(blob => {
// your code
});
}); the memory leak comes from those iframes. works for me in rendering 10000+ images, 200 max without this fix. |
Any Update? I am using latest 1.4.1. Calling 10 times itself crashing chrome. aw snap coming. |
|
Squashed commit of the following: commit 96cc89a Author: yuyuyzl <yuzhongliang221@gmail.com> Date: Tue Sep 6 10:36:07 2022 +0800 fix: cleanup iframe first to prevent memory leaks, see niklasvh#1609 commit 485a49e Author: yuyuyzl <yuzhongliang221@gmail.com> Date: Tue Sep 6 10:28:22 2022 +0800 fix: cleanup iframe first to prevent memory leaks, see niklasvh#1609
Bug reports:
Calling html2canvas multiple times increases memory usage.
Specifications:
How to reproduce
It appears the clean up of the cloned nodes is not working as expected, or Chrome isn't cleaning it up.
The text was updated successfully, but these errors were encountered: