4.8.1 can not recover from WebGL Context loss due to the following reasons:
1) All webgl textures have to be released on context loss.
This is done by TextureManager using TextureManager.managedTextures list.
However, WebGLRenderer.handleContextRestored() calls _initContext() which is creating new instance of TextureManager, thus managedTextures list gets emptied. All textures created before context loss are not tracked anymore, especially textures created by PIXI.Text.
Solution: Pass old ManagedTextures list to new TextureManager instance in handleContextRestored():
let temp = thistextureManager._managedTextures;
this._initContext();
this.textureManager._managedTextures = temp;
2) PIXI.mesh.NineSlicePlane should rebuild vertex and index buffers.
gl.canvas.addEventListener( "webglcontextrestored",
( e ) =>
{
this._glDatas = {};
this.dirty++;
this.indexDirty++;
this["vertexDirty"] = this["vertexDirty"] + 1;
}
, false
);
3) PIXI.Graphics should delete all gl* data:
gl.canvas.addEventListener( "webglcontextrestored",
( e ) =>
{
let a: any = this;
a._webGL = {};
a.dirty = a.dirty + 1;
}
, false
);
WebGL context loss can be tested in Chrome using extensions:
ext = gl.getExtension( 'WEBGL_lose_context' );
ext.loseContext();
ext.restoreContext();
I think I fixed that before. Try latest version? pixijs.download/v4.x/pixi.js
I'm sure that I fixed at least point 1 from your list.
Any follow-up @RomanLut ?
Not fixed in 4.8.7. Does not survive lost context.
I think you can easily reproduce it in any project with:
ext = gl.getExtension( 'WEBGL_lose_context' );
ext.loseContext();
ext.restoreContext();
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Not fixed in 4.8.7. Does not survive lost context.
I think you can easily reproduce it in any project with:
ext = gl.getExtension( 'WEBGL_lose_context' );
ext.loseContext();
ext.restoreContext();