stackgl/headless-gl

Fix no display found error on Node 12.13.1+ on macOS

dhritzkiv opened this issue ยท 7 comments

While attempting to fix the CI issues on macOS, it became apparent that headless-gl doesn't work on macOS with nodejs 12.13.1 and higher. nodejs 12.13.0 still works, believe it or not.

I have not been able to pinpoint the cause of the breakage yet. All I know is that it's unrelated to the building of the native module with gyp (as building on 12.13.0, then running 12.13.1 doesn't work). It's likely a runtime issue.

It seems that eglInitialize in webgl.cc fails in node 12.13.1.

I believe I've narrowed down the change in node that may have brought this about.

This commit to node (nodejs/node@2764567f90) upgraded libuv. Inside the upgrade was this insignificant, seemingly unrelated change: libuv/libuv@038eacf

As crazy as it sounds, the process-title code may be the culprit. (!!)

Why do I suspect this? Three years ago when first working with headless-gl, I noticed that my implementation suddenly stopped working on OSX. I eventually traced it back to me setting process.title to some value. I scratched my head, removed the process.title line, and moved on without thinking too much more about it.

In fact, you can re-create the behaviour of this issue's bug in Node 12.13.0 and below by simply doing this in any JS file that is required by the process:

process.title = "Foo";

// the rest of your code

I'm planning to build node from source just before that commit and just after that commit to confirm my suspicions. As for the next steps after that? No idea.

Amazingly, more digging turned up this issue: libuv/libuv#2566 (and nodejs/node-gyp#1981)

Not exactly our problem, but looks extremely related.

The suspect code has been reverted in libuv, but a new version hasn't been created. It might be some time before it makes its way into a new node release. Hopefully any libuv upgrade will also make it into node v12.

Unfortunately, I don't believe there is anything to do on our end.

The README will need to be updated to note the total breakage in certain version ranges of node.

Wow, that's super obscure! Good work on narrowing down the issue. Yeah, it seems there's nothing we can do but declare a certain range of Node versions unsupported.

Thank you for digging into the issue.
I noticed Node v13.7.0 has been updated libuv (https://github.com/nodejs/node/releases/tag/v13.7.0)
so, I tested;
Node v13.7.0 + gl v4.4.1, it's working. (while installing, I got some warnings)
Node v13.6.0 + gl v4.4.1, it does not work. (while installing, I got some warnings as well)
I didn't tested deeply, something won't work possibly but I'd like to let you know that.

Thank you so much for contribution and maintenance!

FYI:
Machine Specs.
MacBook Pro (Retina, 15-inch, Mid 2014)
MacOS Catalina 10.15.2

Thanks for updating this thread, @Nismit. Looks like 13.7.0 includes the fix. I've submitted an issue to nodejs (nodejs/node#31623) to back port the changes to the 12.x line.

I'll close the issue when nodejs 12.x (or the next LTS) is working again.

Perfect. Thank you for hard working for it.
Hope it will be approved.

Fixed with the releases of Node v12.16.2 and v13.7.0