Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGL Context Loss Support #357

Closed
wants to merge 3 commits into from
Closed

Conversation

mattdesl
Copy link
Contributor

There are a lot of bugs with context loss. For debugging, you can simulate context loss like so (in Chrome);

var loseCtx = this.gl.getExtension("WEBGL_lose_context");
loseCtx.loseContext();

... after some time ...
loseCtx.restoreContext();

I also did a bit of code tidy in WebGLRenderer. Here is a run-down of the issues that were fixed:

  • Context was not getting restored with the correct options (antialiasing, etc)
  • Context was not getting restored with correct GL states (blending, depth test, etc)
  • WebGLBatch was not re-settings its buffers after initialization.
  • WebGLRenderGroup was not activating the default shader before rendering.
    So if another shader was previously bound (i.e. line strip) this would cause errors on context restore.
  • WebGLRenderer.handleContextRestored was trying to call a method that didn't exist
  • PIXI.gl wasn't getting set on context restore.
  • destroyTexture was using gl.createTexture() before deleting it; thus rendering the method useless. fixed now
  • Changed a invalid script tag in Example 7 (unrelated to Context Loss, but a simple fix...)
  • backgroundColor in WebGLRenderGroup was not used
  • "batch" in WebGLRenderer was not used, removed
  • "batchs" array in WebGLRenderer was not used, removed

There are still some outstanding bugs:

  • TilingSprite, RenderTexture, Graphics, Stirp, and other extras don't seem to be handling context loss at all. Instead of me making a change, I feel like these should be overhauled to have a unified underlying base class, kind of like what we've got started with CustomRenderer.
  • PIXI._restoreBatchs, PIXI._returnBatch and PIXI._getBatch seem like they duplicate functionality that should be in WebGLRenderGroup. This should really be changed. Also, static globals should be removed to better support multiple canvases and contexts, and make a cleaner API.
  • Context loss is not fully supported with certain examples, namely look at the Bitmap Text example with a simulated context loss. I suspect it has something to do with bitmap loading?

Also, if batch features ever become part of the public API, we should use the naming "batches" instead of "batchs".

@GoodBoyDigital
Copy link
Member

The new dev branch now has context loss support - couldn't merge this though as the new renderer is quite different! Thanks for all the help though @mattdesl

@lock
Copy link

lock bot commented Feb 25, 2019

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.

@lock lock bot locked and limited conversation to collaborators Feb 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants