Skip to content

tileserver-gl-light is broken. maplibregl missing since version 5.2.0 #1488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DVLP opened this issue Apr 14, 2025 · 19 comments · Fixed by #1490
Closed

tileserver-gl-light is broken. maplibregl missing since version 5.2.0 #1488

DVLP opened this issue Apr 14, 2025 · 19 comments · Fixed by #1490

Comments

@DVLP
Copy link

DVLP commented Apr 14, 2025

I don't have full tileserver-gl and I ran a simple example with tileserver-gl-light 5.2.0

Upon opening localhost:8080, getting this

basic-preview/?vector:61 Uncaught ReferenceError: maplibregl is not defined
at basic-preview/?vector:61:7

This line in code

      maplibregl.setRTLTextPlugin('/mapbox-gl-rtl-text.js' + keyParam);

I managed to get it working by downgrading to 5.0.0, then 5.1.3 also worked

Broken version is 5.2.0
Cause: missing maplibregl

This and other errors from the console

Image

@DVLP DVLP changed the title light version is broken tileserver-gl-light is broken. maplibregl missing since version 5.2.0 Apr 14, 2025
@acalcutt
Copy link
Collaborator

Are you using the docker release or just straight through npm?

In 5.20 all the libraries we changed to be installed as part of prepare #1427 , so those js files are supposed to get copied to the public/resources as part of the npm install

@acalcutt
Copy link
Collaborator

acalcutt commented Apr 15, 2025

I tested the docker version of light 5.20 and it seemed to work as expected.

@DVLP
Copy link
Author

DVLP commented Apr 15, 2025

Running directly from npm on Windows like this:
npm i -g tileserver-gl-light
tileserver-gl-light data/whatever.mbtiles

btw my current Node is v23.6.1

@acalcutt
Copy link
Collaborator

acalcutt commented Apr 15, 2025

If you use node v22 does it make a difference? In maplibre-native we only publish binaries for even LTS releases right now, so node v23 would not be supported.

@DVLP
Copy link
Author

DVLP commented Apr 15, 2025

Let me check, meanwhile I found this.
Image

@DVLP
Copy link
Author

DVLP commented Apr 15, 2025

Tried with 22 and it's the same as with 23

@acalcutt
Copy link
Collaborator

acalcutt commented Apr 15, 2025

I think the issue is the publish.js script is removing the 'prepare' section of the the package.json in https://github.com/maptiler/tileserver-gl/blob/master/publish.js#L40

We need this line now though, because it copies over the all the js files
https://github.com/maptiler/tileserver-gl/blob/master/package.json#L9

When I install light globally I can see that line doesn't exist
Image

@okimiko do you agree?

@acalcutt
Copy link
Collaborator

acalcutt commented Apr 15, 2025

Can you test this as a workaround?

1.) Open a command prompt to your tileserver-gl v5.20 folder. when I installed globally it ended up in
C:\Users\username\AppData\Roaming\nvm\v22.14.0\node_modules\tileserver-gl-light

2.) Install the js files by running
npm run copy:maplibre && npm run copy:maplibre-inspect && npm run copy:mapbox-rtl-text && npm run copy:leaflet && npm run copy:leaflet-hash

3.) try running tileserver-gl again

@DVLP
Copy link
Author

DVLP commented Apr 15, 2025

After manually triggering all the copy scripts the map works but the console is giving some errors

Image

@okimiko
Copy link
Contributor

okimiko commented Apr 15, 2025

@acalcutt: Yes, I agree: The prepare is responsible for the dependency integration.

@DVLP:

@acalcutt
Copy link
Collaborator

acalcutt commented Apr 15, 2025

Like mentioned the new error is unrelated. are you using the default switzerland mbtiles file there? that file is an older version of the schema where aerodrome_label might not exist. if you look at inspect you should see if that layer actually exists, like
Image

Usually I only use the built in style and data for testing. It is usually a good idea to get the latest version of the style (like from https://github.com/openmaptiles/osm-bright-gl-style ) and create an update mbtiles file (you can use something like planetiler or the openmaptiles tools (I prefer planetiler myself))

At some point maybe I should ask @klokan for the rights to update tileserver-gl-styles https://www.npmjs.com/package/tileserver-gl-styles , but right now I don't have the permission needed to update it

@okimiko would you possibly submit a PR to remove this line https://github.com/maptiler/tileserver-gl/blob/master/publish.js#L40

@DVLP
Copy link
Author

DVLP commented Apr 15, 2025

@okimiko The first error comes from the basic preview.
btw. When I click on Inspect in OpenMapTiles I'm not getting any errors. I see both errors when I click on "Vector" in Basic preview.
The second issue must be some error that gets caught and incorrectly rethrown as the file is there. I tried pausing on every caught error but the error is inside a worker and this is very convoluted. Looks like importScripts fails, and "e.bD.isParsed()" is false

Image

@acalcutt I'm using Monaco mbtiles, provided from the outside. With 5.1.3 I'm not getting neither of the errors.

These are my options
Image

@acalcutt
Copy link
Collaborator

acalcutt commented Apr 15, 2025

the reason you don't see an error in inspect is because your style is trying to use a layer that doesn't exist and/or has been renamed. that is why I mention it is always good to update the style (and use a config json file to point to it) . the version of the style included is oudated and there are updates to it at https://github.com/openmaptiles/osm-bright-gl-style/releases that account for the openmaptiles schema changes.

Inspect only lists layers in your data sources vector_layers metadata.

@okimiko
Copy link
Contributor

okimiko commented Apr 15, 2025

I added the PR for the re-added prepare script.

PS: And I could reproduce the 'uncaught promise' error, but only with a explicit node (20.18.1) run (in docker) of the light build, but not with the docker builds (normal and light) ... Strange.

@acalcutt
Copy link
Collaborator

acalcutt commented Apr 16, 2025

I tried merging the PR #1489 thats add 'prepare' back into the light version, but it seems 'prepare' is not run when you install a package globally. 'prepare' is supposed to be run before the npm publish, but the files being copied are just not being included in the package because we exclude them in .gitignore

It seems like the recommended way to fix that would be to specifically list the files that should be included in the package, which is what I am testing in #1490 . This allows the js files to be included in the npm package. I read you could also use .npmignore, but having both that and .gitignore could lead to confusion and explicitly listing the files was preferred.

I think we could also change 'prepare' to 'postinstall'. 'postinstall' does get run when installing a package globally, so it could be an alternative to including the files in the package.

@acalcutt
Copy link
Collaborator

acalcutt commented Apr 16, 2025

Can you give tileserver-gl-light v5.2.2-pre.0 a try and tell me if it works better. the js files should now get included in the package
npm i -g [email protected]

@okimiko
Copy link
Contributor

okimiko commented Apr 19, 2025

@DVLP: 5.3.0-pre.0 should fix the rtl issue, which was caused by an version mismatch between maplibre-gl-js and the rtl plugin.

@DVLP
Copy link
Author

DVLP commented Apr 20, 2025

@acalcutt @okimiko Thanks, I'll check it out soon after I'm back to related works

@DVLP
Copy link
Author

DVLP commented Apr 21, 2025

@acalcutt @okimiko 5.3.0 is working well, thanks.

@DVLP DVLP closed this as completed Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants