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.12k stars 614 forks source link

Map Fonts: 400 Bad Request #1268

Closed vzkharov closed 23 hours ago

vzkharov commented 1 month ago

Locally all works great, even Roboto fonts are got.

Local Machine:

But on Hetzner Server when fonts are requested — 400 Bad Request

Production Setup:

GET /data/planet/3/4/3.pbf 200 439858 - 19.311 ms
GET /data/planet/4/8/4.pbf 200 175999 - 11.599 ms
GET /data/planet/4/8/5.pbf 200 375107 - 17.883 ms
GET /data/planet/4/9/4.pbf 200 193329 - 25.560 ms
GET /data/planet/4/9/5.pbf 200 314155 - 41.204 ms
GET /data/planet/4/9/6.pbf 200 345074 - 41.865 ms
GET /data/planet/4/8/6.pbf 200 303923 - 6.839 ms
GET /fonts/Roboto-Bold/7168-7423.pbf 400 2 - 1.494 ms
GET /fonts/Roboto-Bold/1024-1279.pbf 400 2 - 3.183 ms
GET /fonts/Roboto-Bold/256-511.pbf 400 2 - 1.753 ms
GET /fonts/Roboto-Regular/8192-8447.pbf 400 2 - 6.302 ms
GET /fonts/Roboto-Regular/7168-7423.pbf 400 2 - 6.767 ms
GET /fonts/Roboto-Regular/512-767.pbf 400 2 - 7.134 ms
GET /fonts/Roboto-Regular/1024-1279.pbf 400 2 - 10.770 ms
GET /fonts/Roboto-Regular/256-511.pbf 400 2 - 6.759 ms
GET /fonts/Roboto-Bold/65024-65279.pbf 400 2 - 5.670 ms
GET /fonts/Roboto-Regular/0-255.pbf 400 2 - 5.613 ms
GET /fonts/Roboto-Bold/4864-5119.pbf 400 2 - 2.697 ms
GET /fonts/Roboto-Bold/64256-64511.pbf 400 2 - 2.657 ms
GET /fonts/Roboto-Bold/4608-4863.pbf 400 2 - 4.108 ms
GET /fonts/Roboto-Bold/768-1023.pbf 400 2 - 2.11

(setup)

Starting tileserver-gl-light v4.10.3
Using specified config file from config.json
Starting server
Listening at http://[::]:3001/
Style "basic" changed, updating...
Style "brand" changed, updating...
Startup complete
GET / 200 3068 - 44.217 ms

Any ideas how to fix this?

prashis commented 1 week ago

In the protocol-buffers package, I encountered the deprecated new Buffer usage, and I wasn't getting any errors after modifying it. The package @mapbox/glyph-pbf-composite uses an old version of protocol-buffers that still relies on new Buffer.

        ('if (!buf) buf = Buffer.alloc(encodingLength(obj))')
acalcutt commented 1 week ago

@prashis So does that cause the mentioned issue? seems strange it would work in oneplace and not the other. It looks like to fix it we would likely have to fork @mapbox/glyph-pbf-composite or move the functions into tileserver-gl, since that package doesn't seem maintained anymore.

Just a note for the original post, as of 4.8.0, Ubuntu 22.04 is required for linux. without that maplibre-native will be missing dependencies and crash when used. (unless you are using docker)

jessekrubin commented 1 week ago

Try this (same api): https://github.com/jessekrubin/pbfont ?

I have not used tileserver-gl, but a tileserver-gl user found my lib and sent me this issue.

prashis commented 1 week ago

@acalcutt I've tried using https://github.com/jessekrubin/pbfont instead of @mapbox/glyph-pbf-composite & this issue was resolved. Could we use @jsse/pbfont?

(I was using a docker container for debugging)

acalcutt commented 1 week ago

Its seems like a good alternative that is more up to date. The license for it is MIT so it is compatible. I wouldn't mind a PR for that change.

jessekrubin commented 6 days ago

FWIW it works well on front end and backend. I am compositing glyphs both places.

PS: if you're into map tiles you might like some of the tools I have made. 🔌

steve-maptaskr commented 3 days ago

I suspect this may be related to: https://github.com/maptiler/tileserver-gl/issues/1295

acalcutt commented 21 hours ago

Can anyone confirm v4.12.0 fixes this.

steve-maptaskr commented 11 hours ago

I can confirm that with Node 20.15.0, and v4.12.0 the new @jsse/pbfont is functioning as expected, and there are no longer any issues. Thank you all very much!

jessekrubin commented 9 hours ago

Anytime Steve! It definitely beats having to composite the fonts by hand w superglue.