Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysteriously invalid OpenGL context in Electron

I've created an C++ & OpenGL animation engine backed by GLX and GLEW, wrapped in a Node.js module via SWIG. The goal is to use the engine inside an Electron app in the browser process.

The engine appears quite stable. It's multi-context aware, binding the correct OpenGL context before all relevant operations, checking for errors after almost every possible operation, and backed by a rather large testing suite.

Outside of an electron app everything is working just fine. Mysteriously however, simple scripts that would normally work outside of Electron are failing inside an Electron app in either browser or renderer process.

Symptoms

  • Anything generated by glGenX is returning 0
  • glGetString(GL_VERSION) returns null, afterward glGetError returns no error

Facts

In this order:

  • The OpenGL context is created with glXCreateContextAttribsARB with a reasonable FB config. The returned value is non-zero.
  • XSync(display, false) is being called to wait for X errors. No errors are crashing the program, setting an X error handler yields no results.
  • The context is made current with glXMakeCurrent, no errors reported by glGetError.
  • The context is direct, checked with glXIsDirect.
  • GLEW is initialized with glewInit, returning GLEW_OK.
  • The actions in this case are occurring within the same thread. In the Electron app, the context is made and immediately used in the same process; The creation of the context itself queries the version within the same method. Same symptoms before and after the Electron app is 'ready'.

I'm pretty baffled by this. Everything I'm checking appears to suggest the context was created correctly but it otherwise appears corrupted or dysfunctional.

What's going on? What else can I check?

like image 750
Litty Avatar asked Jun 13 '17 03:06

Litty


1 Answers

https://github.com/electron/electron/issues/8848 reports exactly the issue of a null GL_VERSION and blames Electron version 1.6.1. The workaround was to roll back to version 1.4.15.

like image 64
mikep Avatar answered Sep 24 '22 20:09

mikep