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)

Most upvoted comments

@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.

image

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

However, any way to check which renderer pixi is using? (Since “webgl context lost” is not reliable sign)

@JoepSchyns Add hello: true to the options for creating Application 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 use app.renderer instanceof PIXI.Renderer for WebGL renderer and app.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 use app.renderer.type === RENDERER_TYPE.WEBGL and app.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)

  • pixi.js : 5.1.6 (also 4.0.0 used on the official website)
  • Tested browsers : Firefox 75, Firefox Developer Edition 76 beta 4, Chromium 81.0.4044.92
  • Distro : Arch Linux 5.4.31-1 LTS
  • Hardware : Ryzen 5 2400G (Vega disabled), 16GB RAM, RX 480 8GB
  • amdgpu : 19.1.0-1
  • mesa : 20.0.4-1
  • xorg : 1.20.8-1