pixijs: What happens when WebGL context is lost?
-
pixi.js
version: _e.g.5.2.1 -
Browser & Version: Firefox 74.0
-
OS & Version: OpenSuSE 43.1
This is a question again: when I see “Error: WebGL context was lost.”, does this mean that pixi falls back to canvas drawing? I see this when I try to load my code in Firefox and the result is very slow and laggy - the animation stutters. When opening the same script in chromium, I don’t see the error message and the animation is very smooth.
Perhaps chrome is just a lot faster? What’s a good way to debug this?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 18 (3 by maintainers)
@JoepSchyns This reason why “WebGL context was lost.” message occurs in Firefox is that PixiJS creates a temporary WebGL context to detect whether WebGL is supported, then try to delete the context by using
gl.getExtension('WEBGL_lose_context').lostContext()
. This will cause Firefox to show an warning in console. It doesn’t affect the normal execution of the code, just a little annoying.Ha, Stalebot, we meet again. This issue still happens for us, Firefox is losing context without much debug info nor directions on how to fix this issue. Happy to contribute to this, we have a strong interest in fixing this bug
@JoepSchyns Add
hello: true
to the options for creatingApplication
will show a message with renderer type in console (the message will show up automatically if you are using PixiJS v6). If you want to check this in you code, you can useapp.renderer instanceof PIXI.Renderer
for WebGL renderer andapp.renderer instanceof PIXI.CanvasRenderer
for canvas renderer.(Your question let me found that
app.renderer.type
is broken, see #9218. After this is fixed (hopefully for 7.2.0) you can useapp.renderer.type === RENDERER_TYPE.WEBGL
andapp.renderer.type === RENDERER_TYPE.CANVAS
to check the renderer’s type!)Hi, similar issues under Firefox 75 (also Firefox dev 76 beta 4). I also have this, after refreshing the page a couple of times :
Exceeded 16 live WebGL contexts for this principal, losing the least recently used one. isWebGLSupported.js:31:32
WebGL context was lost. isWebGLSupported.js:31:32
I also have serious performance issues. For example, the demo shown on PixiJS official website (https://www.pixijs.com/) is very slow and choppy and I have a lot of CPU usage as well. On Chromium, it runs smoothly and does not show any sign of lost context in console. Other js WebGL libraries, are slow as well, it’s a browser related issue.
When testing 3D WebGL examples, both browsers show slowdowns…
I’ve read that Firefox and Chromium works best with Wayland. Their implementation of WebGL 2 for X11 is still a work in progress, while Chromium has the best support today (but still far from being perfect, especially in 3D). Apparently, WebGL 1 is better supported for X11 but as far as I’ve tested, it’s the same for me. I personally use X11 (xorg), and I think that’s why I have such poor performance.
The Firefox development team is currently working on it, but they started a month ago, so we will need to wait a bit before starting to see an improvement. https://bugzilla.mozilla.org/show_bug.cgi?id=1010527 https://bugzilla.mozilla.org/show_bug.cgi?id=1580166
That’s also explains why Windows users don’t experience this issue, as Firefox uses DXGL to render on this platform.
MacOS users probably have performance issues as well.
EDIT : The issue has been solved. The current Firefox Nightly build (77.0a1) shows more than 50 FPS on the Pixi.JS website (performance log) and the 3D WebGL aquarium runs at 60 FPS with 1000 fishes (https://webglsamples.org/aquarium/aquarium.html). But, the contexts are still lost and shows the same lost context issues after refreshing the page a couple of times, indicating that this time, it’s pixi.js’ fault. (see the top of my comment)