My problem :
uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: file:///***************.js :: redrawView :: line 308" data: no]
The code which produce this behaviour (tmpImg is loading dynamically, so if it is not loaded yet, it skip it).
if(tmpImg!=null && tmpImg.img.complete===true && tmpImg.img.src!=null){
var tmpPos = i_getCoordsImage(tmpImg);
var rect = getRectInCurrentView(tmpPos.x,tmpPos.y,tmpPos.w,tmpPos.h);
console.log(tmpImg);
console.log(rect);
mainDisplayContext.drawImage(tmpImg.img,rect.x,rect.y,rect.w,rect.h);
}
The problem happens several times when the tmpImg is just loaded (a least according to Firebug's log), and then disappear.
The code snippet is called several times in a row, so I can't see if the image is actually displayed when the error is thrown.
The value in rect.* are floating point, something like {x:-1500, y:-2500,h:1000,w:1000}
Do you have any idea about the origin of this error ?
Edit 1
This code produce the error (you need to have an image named "test.png" in the same directory
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta charset="UTF-8" />
</head>
<body id="body">
<canvas id="canvas" width="600" height="600"></canvas>
<script>
//[CDATA[
var img = new Image();
var mdc = document.getElementById("canvas").getContext("2d");
function displayCallback(){
if(img.complete===true && img.src!=null){
mdc.drawImage(img,0,0,600,600);
}
setTimeout(displayCallback, 50);
}
setTimeout(function(){img.src = "test.png";}, 10000);
setTimeout(displayCallback, 1000);
//]]
</script>
</body>
</html>
It seems related to the fact that the empty image has a src propriety of "". Is it always true ?
edit 2
In fact, for the bug reporting, this JavaScript would suffice (if I understood) :
document.getElementById("canvas").getContext("2d").drawImage(new Image(),0,0);
See Question&Answers more detail:
os