maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.24k stars 639 forks source link

Future of mapbox-gl-native #542

Closed mnutt closed 2 years ago

mnutt commented 3 years ago

Node 10 was end-of-lifed yesterday, and unfortunately one of tileserver-gl's primary dependencies (mapbox-gl-native) only runs on node 10. The mapbox-gl-native node bindings seem to unfortunately be in limbo; the latest releases don't actually seem to build on any node version or platform and only work at all because they rely on downloading binary blobs on npm module install.

I am exploring @naturalatlas/mapbox-gl-native, a fork of mapbox-gl-native, which also fixes a rendering issue[0] but am noticing a new issue with it: it seems that in newer mapbox-gl-native, using mode: "tile" means that only a single tile will be loaded per map render. This means that static requests will often be missing tile data. In adding mbgl logging, I see:

{ class: 'General',
  severity: 'WARNING',
  text:
   'Provided camera options returned 4 tiles, only 14/8571/5737=>14 is taken in Tile mode.' }

I haven't confirmed, but I wouldn't be surprised if this is upstream in @mapbox/mapbox-gl-native in unreleased versions too.

So it seems that going forward it may not be possible to have a single Map that can render both tiles and static maps: mode: "static" is needed to render static maps with multiple tiles, while rendering tiles continues to need mode: "tile" to remedy https://github.com/maptiler/tileserver-gl/issues/344.

If this is the case, perhaps it would make sense to have separate pools for static and tile. Or maybe there's another better way?

There is also another fork called @maplibre/maplibre-gl-native but they don't have newer node support yet. Hopefully they'll either adopt @naturalatlas's patches, or develop n-api bindings.

[0] (rendering issue)

Adding map overlays with image icons basically works, but on some platforms (linux xvfb) the transparency is incorrectly high. Switching from @mapbox/mapbox-gl-native to @naturalearth/mapbox-gl-native fixes it. Example:

Map with image marker rendered with canvas on top of map: 240x186

Map with same image marker added as layer, using @mapbox/mapbox-gl-native:

240x186-incorrect
AndyHuska commented 3 years ago

I agree this needs to be taken care of, and the maplibre project seems like the best place to put the effort since it supports the entire "mapbox" suite. Maplibre is still working on phase 1 of the refactoring project, after that they will catch up on things like this and start adding features.

mnutt commented 3 years ago

My understanding from looking at mapbox-gl-native's commit history is that besides not wanting to keep up with nan's upgrades, node support added a bit more complexity in requiring libuv for the runloop, especially on non-linux platforms.

I've split out the runloop here: https://github.com/maplibre/maplibre-gl-native/compare/master...mnutt:node-14?expand=1 and tested it on linux and mac but I'm just getting familiar with cmake so it's likely not quite right yet.

vinayakkulkarni commented 2 years ago

Yep, I had to debug this for almost 4 hours & ended up setting v10 in the projects .nvmrc, upgrading to latest node or at least latest LTS is mandatory

mnutt commented 2 years ago

If you're just building it for yourself, my branch above should work ok.

acalcutt commented 2 years ago

This should be completed.

In https://github.com/maptiler/tileserver-gl/pull/602 we upgraded to Maplibre-Native

In https://github.com/maptiler/tileserver-gl/pull/608 I added a separate pool of renderers that are in static mode instead of tile mode, to be used by these static endpoint