maplibre-native
maplibre-native copied to clipboard
[NodeJS] Are there any plans to keep up with nodejs binaries support?
https://github.com/maplibre/maplibre-gl-native/tree/master/platform/node
Node binaries of the original project stopped at Node 10, I managed to build in Node 11 but not 12. There was a fork with 12-14 bindings but I never managed to get that to work in my code.
I think it would need a refactor and maybe a change of build libraries to get the bindings working?
https://github.com/mapbox/mapbox-gl-native/issues/16485
Here is the thread.
I've had success with using @naturalatlas/mapbox-gl-native
on node 10 and 14 / linux, but not on any version of node on macos. I'm wondering if it's related to this warning they added to CMakeLists: https://github.com/mapbox/mapbox-gl-native/blob/master/platform/node/CMakeLists.txt#L48 My experience on macos was that map rendering just hung and CFRunLoop never fired.
I was able to get this to work on MacOS by replacing MacOS's loop system with libuv, like so: In mapbox-gl-native/platform/macos/macos.cmake, I had to add this:
target_include_directories(
mbgl-core
PUBLIC /usr/local/opt/libuv/include/
)
Comment these out:
# ${PROJECT_SOURCE_DIR}/platform/darwin/src/async_task.cpp
# ${PROJECT_SOURCE_DIR}/platform/darwin/src/run_loop.cpp
And add these:
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/run_loop.cpp
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/util/async_task.cpp
Unfortunately though, I haven't been able to get naturalatlas to run headless in a docker container... any luck with that?
I did a bunch of experimenting and got most things working here:
https://github.com/maplibre/maplibre-gl-native/compare/master...mnutt:node-14?expand=1
It looks like the node runloop support was left behind in the build system refactoring that happened in mapbox a while back; this splits a platform-dependent runloop back out into its own cmake target.
While that branch works for me, what I really wanted to do was generate prebuilt binaries and I'm having a lot of trouble paring down the dependencies; the binaries that I generate are small and have lots of linked libraries whereas the prebuilt binaries mapbox generated were quite large because they statically linked most things.
My other goal with that is to completely remove the need for xvfb on headless linux, but that has a ways to go I think.
@mnutt did you go further in this direction ?
I am looking for a solution to include maplibre-gl-native in a docker image with a recent node version if possible. If no solution is available right now I am looking for the next best thing : some indication of where to dig deeper and solve the problem myself.
Mine works fine if you are willing to build the node module as part of the docker image build: it’ll dynamically link to a bunch of things, but they’ll be available. It’s pretty far off from being to npm install @maplibre/maplibre-gl-native
from a machine with no dependencies installed, but if you just want to npm install in docker you should be ok to do so.
A lot of the work on this was completed here: https://github.com/maplibre/maplibre-gl-native/pull/217. Last step would just be to publish the binaries and publish the package to npm to make it easy for people to npm install
.
https://www.npmjs.com/package/@maplibre/maplibre-gl-native