mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
4.36k stars 1.33k forks source link

Request: Node v12 binaries? #16418

Closed samdelacruz closed 4 years ago

samdelacruz commented 4 years ago

Would it be possible to publish binaries for node.js 12 (current LTS)? Currently only able to use the npm module with version 10.

Platform: Node.js v12.16.1 Mapbox SDK version: v5.x

Steps to trigger behavior

  1. nvm use 12
  2. npm install @mapbox/mapbox-gl-native

Expected behavior

Install succeeds

Actual behavior

Install fails:

403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/@mapbox/mapbox-gl-native/v5.0.2/node-v72-darwin-x64-Release.tar.gz
tmpsantos commented 4 years ago

Hi @samdelacruz, the Node bindings are not being actively developed, that is why we are not making new releases. Unfortunately, the team working on the GL Native engine no longer has the bandwidth to maintain, test and keep up with the latest Node releases and V8 API breakages. The last patch was to blacklist Node ABI 83 because it did not compile.

Moving forward, GL Native now can be used as a CMake subproject, that is how Android and iOS are doing. I published here a skeleton of how this project could be kickstarted. I'm happy to help anyone interested on maintaining these bindings. It is not much code to be honest, but the main complexity is with dealing with V8 and NAN.

markgis commented 4 years ago

Hi @tmpsantos, been trying to get your skeleton https://github.com/tmpsantos/mapbox-gl-native-node to work and create bindings for Node > 12 but struggling so far.

I thought a NAN version bump fixed it at first but still cant get builds past ABIS 64 working yet. Cant say I know a lot about Node bindings from C++, some of the NAN docs looked promising though in terms of dealing with the V8 changes. Any suggestions where to start on getting at least a build working?

tmpsantos commented 4 years ago

Any suggestions where to start on getting at least a build working?

Hi @markgis, to be honest, I always struggled a bit with NAN. My suggestion would be to explore new avenues such as port the bindings to https://github.com/nodejs/node-addon-api, since backward compatibility seems to not be a strong requirement. It should also be a lot easier to maintain.

markgis commented 4 years ago

Hi @tmpsantos , cant say I'm a bindings expert by any stretch, but yes I read a lot of people are moving to N-api, apparently thats a lot easier to work with.

However, when I quickly looked at it it seems Mabpox is quite heavily invested in Cmake and nan commands? Are all the compiled CPP files in https://github.com/mapbox/mapbox-gl-native/tree/master/platform/node/src transferable to a new bindings - i..e N-API. or would it have to be from https://github.com/mapbox/mapbox-gl-native/tree/master/src/mbgl ?

Also I got builds to work in Node 11 , so not sure if thats worth making a PR on Mapbox-native so at least people can jump one Node version higher if needed.

tmpsantos commented 4 years ago

@markgis a new N-API bindings would replace https://github.com/mapbox/mapbox-gl-native/tree/master/platform/node/src and you can change the files we compile here https://github.com/mapbox/mapbox-gl-native/blob/master/platform/node/CMakeLists.txt.

There are a few examples on how to integrate N-API with CMake here https://github.com/nodejs/node-addon-examples/pull/113/files

brianreavis commented 3 years ago

For anyone interested, we forked @tmpsantos's node binding template and added support for Node 12, 13, and 14 in https://github.com/naturalatlas/mapbox-gl-native-node/commit/668a290973e2405c3d28143c7803d01ff5343594 (still using NAN). The repo is here @naturalatlas/mapbox-gl-native. It uses the EGL backend because I for the life of me couldn't get the GLX backend compiling / working on Travis.

npm install @naturalatlas/mapbox-gl-native --save
markgis commented 3 years ago

@brianreavis Brilliant, thanks. I was just starting to look into using N-API, but its all pretty new to me.

creimers commented 2 years ago

@brianreavis I'm getting the following error when trying to build a docker image using @naturalatlas/mapbox-gl-native:

403 status code downloading tarball https://naturalatlas-node-binary.s3.amazonaws.com/@naturalatlas/mapbox-gl-native/v1.0.2/node-v72-linux-arm64-Release.tar.gz

Any idea why that is? Thanks.

brianreavis commented 2 years ago

@creimers That error is because we have not built arm binaries. We don't use the project anymore and I unfortunately don't have any time right now to devote to it. Resolving it will require forking and (1) porting the TravisCI config to use Github Actions, and (2) attempting the arm build and fixing what comes up, I think.

Another thing you could try is simply forking and removing --fallback-to-build=false from https://github.com/naturalatlas/mapbox-gl-native-node/blob/master/package.json#L18 so that pre-gyp will attempt compilation during install when you're building your docker image.

creimers commented 2 years ago

@brianreavis Thank you. I ended up using a different tileserver altogether: https://github.com/consbio/mbtileserver/