组件返回的失败代码:0x80040111(NS_ERROR_NOT_AVAILABLE) [英] Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE)

查看:1808
本文介绍了组件返回的失败代码:0x80040111(NS_ERROR_NOT_AVAILABLE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题:

 未捕获异常:[异常...组件返回失败代码:0x80040111(NS_ERROR_NOT_AVAILABLE)[nsIDOMCanvasRenderingContext2D .drawImage]nsresult:0x80040111(NS_ERROR_NOT_AVAILABLE)location:JS frame :: file:///***************.js :: redrawView :: line 308data :no] 

产生此行为的代码(tmpImg是动态加载的,

  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);
}

问题发生多次,当tmpImg刚刚加载Firebug的日志),然后消失。

该代码段连续调用几次,因此我无法看到图像是否在错误抛出时实际显示。

rect。*中的值为浮点,如{x:-1500,y:-2500,h:1000,w:1000}



关于此错误的起源的任何想法?



编辑1



产生错误(您需要在同一目录中有一个名为test.png的图片

 <!DOCTYPE html& 
< html xmlns =http://www.w3.org/1999/xhtmlxml:lang =fr>
< head>
< meta charset = UTF-8/>
< / head>
< body id =body>
< canvas id =canvaswidth =600height = 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>

这似乎与空图像的src属性相关。



事实上,对于错误来说, (如果我明白了):

  document.getElementById(canvas)。getContext ).drawImage(new Image(),0,0); 


解决方案

从Firefox获得这种无用的错误消息DOM API调用会抛出未捕获的Javascript异常。实现drawImage的代码 - http://mxr.mozilla.org/ mozilla-central / source / content / canvas / src / nsCanvasRenderingContext2D.cpp#3212 - 出于某种原因返回错误代码NS_ERROR_NOT_AVAILABLE(在C ++ / JS边界处翻译为JS异常) ,它需要绘制图像的所有数据当前不可用。看起来这可能发生,即使当图像被认为是完全加载;我不熟悉这部分的代码,知道为什么这是可能的。



这是我的意见作为偶尔的Firefox内部黑客,你已经发现一个错误浏览器:规范drawImage 在任何情况下都不许可生成带有此错误代码的异常。 (注意在第3243行的注释,似乎误解了规范说的)。请构造一个完整的,自包含的测试用例来演示这个问题,然后我会很乐意帮你提交一个错误报告。 p>

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);

解决方案

You get this kind of unhelpful error message from Firefox when a DOM API call throws a Javascript exception that isn't caught. The code implementing drawImage -- http://mxr.mozilla.org/mozilla-central/source/content/canvas/src/nsCanvasRenderingContext2D.cpp#3212 -- appears to return the error code NS_ERROR_NOT_AVAILABLE (which is translated to a JS exception at the C++/JS boundary) when, for some reason, all of the data it needs to draw the image is not currently available. It appears that this can happen even when the image is considered to be fully loaded; I am not familiar enough with this part of the code to know why that might be.

It is my opinion as an occasional Firefox internals hacker that you have found a bug in the browser: the specification for drawImage does not license the production of an exception with this error code under any circumstances. (Note the comment on line 3243, which seems to have misunderstood what the spec says.) Please construct a complete, self-contained test case that demonstrates the problem, and I will then be happy to help you file a bug report.

这篇关于组件返回的失败代码:0x80040111(NS_ERROR_NOT_AVAILABLE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆