Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating WebGL context. Three js chrome?

Hi I'm getting the error

Error creating WebGL context.
Uncaught TypeError: Cannot read property 'getExtension' of null

This is happening on google chrome 71 but I find it odd because if I open up dev tool and refresh the page it works perfectly fine I'm at a loss to what is causing this any idea's ?

It's worked perfectly fine untill today nothing has changed on the PC or browser. My drivers are all up to date, webgl is enabled...

like image 368
user3112634 Avatar asked Jan 17 '19 09:01

user3112634


People also ask

Why can’t I create a WebGL context on my computer?

Failing to create a WebGL context is most of the times due to the graphics card being too old and/or the manufacturer no longer updating its drivers. Or the drivers not being reliable enough (ie.

Why can't I create a WebGL context in react 18?

Had the same issue when React 18 (concurrent mode) with threejs. Sorry, something went wrong. Failing to create a WebGL context is most of the times due to the graphics card being too old and/or the manufacturer no longer updating its drivers.

Why does chrome say WebGL is unavailable?

"WebGL: Unavailable. Hardware acceleration unavailable" It also shows that the --disable-gpu flag was passed to chrome.exe! Killing all chrome.exe processes and running by executing chrome.exe directly (in C:\Program Files (x86)\Google\Chrome\Application) seems to solve this. Check your shortcuts to ensure the flag isn't getting passed.

How do I stop the WebGL context initializer from looping?

Make sure you're not calling the WebGL context initializer from a listener (e.g. try writing it within your init function with a boolean flag to stop it from looping or stating gl as global variable). The former worked for me and displays the context correctly.


4 Answers

The fix for me was manually enabling WebGL acceleration under Chrome’s feature flags: chrome://flags/

like image 59
Pavel Topinka Avatar answered Oct 02 '22 09:10

Pavel Topinka


I have encountered this several times with THREE.js. It arises for me once memory resources are shared, abandoned, or overwhelmed, for example:

  1. I have a good render loop but then I introduce long tasks.
  2. I perform extensive, continuous testing. As I modify live settings in Chrome Inspector, THREE does not reflect all changes without fail. Memory may not be released until I restart.
  3. I leave the program running overnight. The next morning the browser is froze, black, OOM...
  4. I use multiple instances of a resource, for example Web Audio and Magenta Music. The quality may perceptibly degrade and throw its own errors, but... I will also encounter worse silent errors. For example when I also steam music in another tab, or click audio/video media on Twitter... frozen browser, black screen, WebGL context loss.
like image 22
PartialFlavor_55KP Avatar answered Oct 02 '22 08:10

PartialFlavor_55KP


if you have two GPU installed on your system you might want to try to enable Override software rendering list in chrome://flags/

like image 23
repy Avatar answered Oct 02 '22 08:10

repy


I updated my graphic drivers (NVIDIA) and didn't restart chrome nor the PC, and was having this issue.

I just restarted the PC and now it's fine.

like image 36
HRK44 Avatar answered Oct 02 '22 08:10

HRK44