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.19k stars 633 forks source link

Error when building docker image from source #1295

Closed krasnoludkolo closed 2 months ago

krasnoludkolo commented 3 months ago

Hello. I'm trying to build docker image from source. I'm using:

docker image build . -t tileserver 

docker run --rm -it -p 8080:8080 tileserver:latest

After I open page, there is no map icon (with preview) and in console I can see:

GET /images/header-map-1280px.png 304 - - 4.803 ms
[Error: Cannot read properties of undefined (reading '0')]
GET /styles/basic-preview/11/1072/717.png 500 2 - 83.664 ms
mlgl: {
  class: 'Style',
  severity: 'ERROR',
  text: "Failed to load glyph range 0-255 for font stack Noto Sans Regular: Cannot read properties of undefined (reading '0')"
}
GET /favicon.ico 304 - - 0.660 ms

When I'm using docker image from repository:

docker run --rm -it -p 8081:8080 maptiler/tileserver-gl:v4.11.1 --verbose

everything works fine.

Full log:

> docker run --rm -it -p 8080:8080 tileserver:latest --verbose

Starting tileserver-gl v4.11.1
No input file found
[DEMO] Downloading sample data (zurich_switzerland.mbtiles) from https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles
[INFO] Automatically creating config file for zurich_switzerland.mbtiles
[INFO] Only a basic preview style will be used.
[INFO] See documentation to learn how to create config.json file.
{
  "options": {
    "paths": {
      "root": "/usr/src/app/node_modules/tileserver-gl-styles",
      "fonts": "fonts",
      "styles": "styles",
      "mbtiles": "/data",
      "pmtiles": "/data"
    }
  },
  "styles": {
    "basic-preview": {
      "style": "basic-preview/style.json",
      "tilejson": {
        "bounds": [
          8.275,
          47.225,
          8.8,
          47.533
        ]
      }
    }
  },
  "data": {
    "v3": {
      "mbtiles": "zurich_switzerland.mbtiles"
    }
  }
}
Starting server
Listening at http://[::]:8080/
Startup complete
GET /health 200 2 - 5.048 ms
GET / 304 - - 38.103 ms
GET /index.css 304 - - 5.675 ms
GET /images/placeholder.png 304 - - 4.367 ms
GET /images/logo.png 304 - - 4.432 ms
GET /fonts/OpenSans-Regular.ttf 304 - - 2.801 ms
GET /fonts/OpenSans-Bold.ttf 304 - - 4.572 ms
GET /images/maptiler-logo.svg 304 - - 5.725 ms
GET /images/header-map-1280px.png 304 - - 4.803 ms
[Error: Cannot read properties of undefined (reading '0')]
GET /styles/basic-preview/11/1072/717.png 500 2 - 83.664 ms
mlgl: {
  class: 'Style',
  severity: 'ERROR',
  text: "Failed to load glyph range 0-255 for font stack Noto Sans Regular: Cannot read properties of undefined (reading '0')"
}
GET /favicon.ico 304 - - 0.660 ms
GET /health 200 2 - 0.985 ms
GET /health 200 2 - 0.565 ms
KevenRing commented 3 months ago

Building tileserver-gl using an RHEL 9 UBI base container yielded similar results. There are no errors displayed with Xvfb. I also confirmed that the only difference in the node_modules directory from the Ubuntu build was the maplibre-gl-native/lib/node-v115/mbgl.node, which had to be recompiled from source for RHEL 9 GLIBCXX version compatibility. The same error is displayed for both True-Type and PBF Fonts. Tiles without fonts appear to render correctly.

steve-maptaskr commented 3 months ago

I can confirm that the issue is caused by the latest version of Node. In the upgrade from the 20.14.0 LTS to 20.15.0 LTS the glyph font "combine" function is throwing the above error.

Tracing the issue, I found the line: https://github.com/maptiler/tileserver-gl/blob/master/src/utils.js#L217 which uses the glyph-pbf-composite library to combine font PBF (protocol buffers).

The specific line is in the package: https://github.com/mapbox/glyph-pbf-composite/blob/master/index.js line

messages.glyphs.encode is throwing the exception, and it is directly related to upgrading to Node 20.15.0.

Changing the Dockerfile to reference the 20.14.0 version of node resolves the issue.

Change Lines: https://github.com/maptiler/tileserver-gl/blob/master/Dockerfile#L40 https://github.com/maptiler/tileserver-gl/blob/master/Dockerfile#L99

to read:

apt-get install -y nodejs=20.14.0-1nodesource1; \

Resolves the issue for now.

If anyone can shed some light as to why the 20.15.0 update has caused the issue that would be awesome!

steve-maptaskr commented 3 months ago

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

ShineLuLu commented 3 months ago

I can confirm that the issue is caused by the latest version of Node. In the upgrade from the 20.14.0 LTS to 20.15.0 LTS the glyph font "combine" function is throwing the above error.

Tracing the issue, I found the line: https://github.com/maptiler/tileserver-gl/blob/master/src/utils.js#L217 which uses the glyph-pbf-composite library to combine font PBF (protocol buffers).

The specific line is in the package: https://github.com/mapbox/glyph-pbf-composite/blob/master/index.js line

messages.glyphs.encode is throwing the exception, and it is directly related to upgrading to Node 20.15.0.

Changing the Dockerfile to reference the 20.14.0 version of node resolves the issue.

Change Lines: https://github.com/maptiler/tileserver-gl/blob/master/Dockerfile#L40 https://github.com/maptiler/tileserver-gl/blob/master/Dockerfile#L99

to read:

apt-get install -y nodejs=20.14.0-1nodesource1; \

Resolves the issue for now.

If anyone can shed some light as to why the 20.15.0 update has caused the issue that would be awesome!

Thank you very much!

acalcutt commented 3 months ago

Can anyone confirm if v4.12.0 fixes this.

steve-maptaskr commented 2 months 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!

KevenRing commented 2 months ago

Confirmed when rebuilding from scratch on RHEL 9. Thanks!

acalcutt commented 2 months ago

Thanks for confirming everyone. I am going to close this. @krasnoludkolo let me know if this didn't fix your issue and we can re-open this.

krasnoludkolo commented 2 months ago

I quickly ran new build and looks like it's fine, thanks! If there is anything wrong, I will comment here