12

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?

Litty
  • 1,856
  • 1
  • 16
  • 35
  • Node.js is always multithreaded, are you calling into C++ asynchronously? – Dietrich Epp Jun 13 '17 at 04:52
  • More accurately put, all my C++ calls are synchronous. The creation of the context and the version query happen within the same C++ method; Unless Node.js is performing some magic I'm unaware of (and only within Electron?), these actions should definitely be occurring on the same thread. – Litty Jun 13 '17 at 04:57
  • How many GL contextes do you create? – Luca Jun 16 '17 at 05:57
  • @Luca Only one in this case, but the engine can handle multiple contexts safely. – Litty Jun 16 '17 at 21:24
  • 1
    Could you provide some code? – DaOnlyOwner Jun 19 '17 at 23:30
  • I don't think glGetError reports GLX errors. Does the glXMakeCurrent call succeed (does it return true)? – geza Jun 20 '17 at 23:40
  • Does Electron even have OpenGL environment support? My gut reaction (and a brief Google) would be no, but if you can find resources saying otherwise I'll happily rescind my question. – mascoj Jun 22 '17 at 21:58
  • @geza Indeed. GLX will throw an error unless an error handler is set. I've set up an error handler just in case, and it is also not catching anything. – Litty Sep 05 '17 at 02:10
  • @mascoj The issue linked in mikep's answer indicates they don't _not_ support it, if that makes sense. Official or otherwise, an older Electron version did support it. – Litty Sep 05 '17 at 02:12

1 Answers1

3

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.

mikep
  • 3,841
  • 8
  • 21