我只是将一吨图像(约5000)装入“新图像()”对象,然后通过调用画布.drawimage(图像, 0, 0)在画布中逐一绘制;
这对 IE10 完全有效, 但一旦我使用 Firefox, 我就会有一个堆叠溢出错误, 因为 Firefox 的记忆用法会上升, 直到溢出。 有人知道原因吗? 我认为 GC 在将图像绘制到画布后不会真正收集我的图像。 即使我正在使用100 个图像对象, 并在绘制图像对象之前将图像对象的弧形循环, 记忆用法会上升和上升。 我将很快测试 Chrome 和 Safari, 但还需要一个解决方案, 因为每个人都在使用“ 最佳浏览器 ” Firefox 。
编辑:
function play() {
//calculated iLag here
//calculated wondow.FrameCtr here
var iFrameRate = Math.round(1000 / 25);
var oImage = new Image();
oImage.onload = function () {
renderImage(this);
}
//window.Video is an array of window.URL.createObjectURL(data) (about 500 items)
oImage.src = window.Video[window.FrameCtr];
oImage = null;
setTimeout(
function () {
play()
}, iFrameRate - iLag
);
function renderImage(oImage) {
$("#video")[0].getContext("2d").drawImage(oImage, 0, 0);
}
I do loop this video (500 items, 25fps) 10 times, and ff isn t even able to play it once, cause of stack overflow. As I mentioned before it is working fine with IE10 and works even better with Chrome, so I don t think the problem here is the recursion. Is there any other way to get binary data into in canvas, than using an Image object and setting the src?