Error: WebGL: Exceeded 16 live WebGL contexts for

2020-03-01 04:01发布

问题:

I have a JavaScript using the THREE.js package, I made some changes, saw the error, and undid all of the changes I have made.

However, the following error remained:

Error: WebGL: Exceeded 16 live WebGL contexts for this principal, losing the least recently used one.

A google-search did not reveal something useful (16 hits!).

Anyone has any idea what is going on? Maybe this error has nothing to do with my script, but with the browser itself?

回答1:

In my case, the solution was as simple as closing the browser window, opening a new one and reloading your project. The error appears only after I've reloaded my project in the same window more than 16 times.



回答2:

I'm seeing this error in FireFox (55) it's happened across a number of small test projects I've been working on.

The only solution I've found is to close and reopen FireFox, which leads me to believe that something isn't getting cleared out upon a page refresh. I've also noticed that leaving my browser open over night can result in very poor performance the following day until I reboot my PC. Perhaps either a Threejs issue or a FireFox (55) one when dealing with WebGL.

I'm going to continue investigating it as I work.



回答3:

There is a fixed number of WebGL context instances available in Chromium, 16: https://code.google.com/p/chromium/issues/detail?id=226868

It is possible you've either got 17+ tabs open simultaneously or you have one or context with a combined pixel resolution greater than 16 * 1024 * 1024.