Hey! 馃憤
I am doing some work with Angular and a Canvas just now which is actually not the best documented thing out there. Anyway I was messing around with Pixi, and I extend PIXI.Application. When I try to destroy the application, I always hit this error.
Does anyone know why this line would be triggered?
Thanks 馃拑
I met the same problem today and got this solved my way.
I tried to cache canvas rendered by PIXI.WebGLRenderer when it's removed from DOM tree so that I could reuse this canvas rather than instantiate a new one when I need to render again. And I met this problem when the reused canvas was rendered.
I solved this problem by caching WebGLRenderingContext of WebGLRenderer as well.
Key error stack of this problem is in SpriteRenderer.js:
this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), settings.SPRITE_MAX_TEXTURES);
The result of gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS) is 0.
The gl here is created by glCore.createContext(this.view, this._contextOptions);, content of which is
var createContext = function(canvas, options)
{
var gl = canvas.getContext('webgl', options) ||
canvas.getContext('experimental-webgl', options);
if (!gl)
{
// fail, not able to get a context
throw new Error('This browser does not support webGL. Try using the canvas renderer');
}
return gl;
};
I don't find any problem of the gl context creation.
So I guess the reason of the problem is that the texture units of this canvas is used by the former gl context and there is none left for the second gl context, so gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS) gets 0.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I met the same problem today and got this solved my way.
I tried to cache canvas rendered by PIXI.WebGLRenderer when it's removed from DOM tree so that I could reuse this canvas rather than instantiate a new one when I need to render again. And I met this problem when the reused canvas was rendered.
I solved this problem by caching WebGLRenderingContext of WebGLRenderer as well.
Key error stack of this problem is in
SpriteRenderer.js:this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), settings.SPRITE_MAX_TEXTURES);The result of
gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)is 0.The
glhere is created byglCore.createContext(this.view, this._contextOptions);, content of which isI don't find any problem of the
glcontext creation.So I guess the reason of the problem is that the texture units of this canvas is used by the former
glcontext and there is none left for the secondglcontext, sogl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)gets 0.