使用mask后,只要调用 Laya.Resource.destroyUnusedResources() 就会引起报错

重现demo如下:

Laya.init(600, 400, WebGL);
let bgSprite = new Laya.Sprite();
bgSprite.graphics.drawRect(0, 0, 200, 200, "#0xFFFF00");
bgSprite.pos(300, 300);
Laya.stage.addChild(bgSprite);

let mask = new Laya.Sprite();
bgSprite.mask = mask;
mask.graphics.drawCircle(0, 0, 100, "0x0000FF");

window.onblur = function()
{
console.log("onblur....?");
Laya.timer.once(2000, null, function()
{
Laya.Resource.destroyUnusedResources();
});
}


当触发了释放资源的函数,会报错如下:
laya.webgl.js:5713
Uncaught TypeError: Cannot read property '_targets' of null
at WebGLContext2D.__proto.drawCanvas (laya.webgl.js:5713)
at RenderContext.__proto.drawCanvas (laya.core.js:5822)
at RenderSprite3D.__proto._canvas (laya.core.js:6219)
at Sprite.__proto.render (laya.core.js:15680)
at RenderSprite3D.__proto._childs (laya.core.js:6201)
at RenderSprite3D.__proto._transform (laya.webgl.js:6758)
at Stage.__proto.render (laya.core.js:15680)
at Stage.__proto.render (laya.core.js:18616)
at Stage.__proto._loop (laya.core.js:18546)
at loop (laya.core.js:5449)

对于这个问题的出现表示不解,为什么mask会被释放了?即使mask是loadImage加载图片来使用,也是一样有这个问题
已邀请:

Laya_Aaron

赞同来自:

感谢反馈,已确认问题,下个版本修复。

fligen

赞同来自:

同样的情况,laya1.0版本,会报如下错误:
cgame.max.js:37344 Uncaught TypeError: Cannot set property 'asBitmap' of null
    at RenderSprite3D.__proto._canvas_repaint (cgame.max.js:37344)
    at RenderSprite3D.__proto._canvas (cgame.max.js:37254)
    at Label.__proto.render (cgame.max.js:57407)
    at RenderSprite3D.__proto._childs (cgame.max.js:37240)
    at RenderSprite3D.__proto._transform (cgame.max.js:56172)
    at RenderSprite3D.__proto._alpha (cgame.max.js:37191)
    at Sprite.__proto.render (cgame.max.js:57407)
    at RenderSprite3D.__proto._childs (cgame.max.js:37240)
    at CTips.__proto.render (cgame.max.js:57407)
    at RenderSprite3D.__proto._childs (cgame.max.js:37240)
 
laya2.0解决了的话,请在1.0版本的基础上也修复一下

要回复问题请先

商务合作
商务合作