Skip to content
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

4.5.2-4.6.1 breaks URL-based "glyphs" and "sprites" (concats URLs with root paths?) #1025

Closed
alex-kowalczyk opened this issue Oct 20, 2023 · 14 comments

Comments

@alex-kowalczyk
Copy link
Contributor

With the following config.json and mystyle.json (relevant fragments) 4.5.1 displays nice map,
while after updated to 4.6.0 it emits errors for glyphs and fonts and does not display vector map at all. Moreover, errors indicate that sprites URLs are concated with local "/data" root prefix.
Revert to 4.5.1 fixed the issue.

Errors on startup:

mlgl: {
    class: 'Style',
    severity: 'ERROR',
    text: "Failed to load sprite: ENOENT: no such file or directory, open '/data/https://static.mydomain.eu/sprites/[email protected]'"
}

Errors when serving:

ERROR: Trying to use Arial Unicode MS Regular as a fallback
ERROR: Font not found: Roboto Condensed Italic
ERROR: Trying to use Arial Unicode MS Regular as a fallback
ERROR: Font not found: Arial Unicode MS Regular
GET /fonts/Roboto%20Condensed%20Italic/0-255.pbf 400 41 - 4.819 ms
ERROR: Font not found: Arial Unicode MS Regular

config.json:

{
  "options": {
    "paths": {
      "root": "/data",
      "styles": "styles",
      "fonts": "",
      "sprites": "",
      "mbtiles": ""
    },
    "domains": [
      "my.domain"
    ],
    "serveAllFonts": false,
    "serveStaticMaps": false
  },
  "styles": {
    "mystyle": {
      "style": "mystyle.json",
      "tilejson": {
        "type": "overlay",
        "bounds": [12.08477,48.54292,18.86321,51.06426]
      }
    }
  },
  "sources": {
     "europe": {
        "url": "mbtiles://{europe}",
        "type": "vector"
     }
  },
  "data": {
    "europe": {
      "mbtiles": "tiles.mbtiles"
    }
  }
}

mystyle.json:

{
  "version": 8,
  "name": "MyStyle",
  "center": [18.4803, 54.46639],
  "zoom": 13,
  "sources": {
    "mystyle": {
      "type": "vector",
      "url": "mbtiles://tiles.mbtiles"
    },
  },
  "id": "mystyle"
  "sprite": "https://static.mydomain.eu/sprites/osm-liberty-topo",
  "glyphs": "https://fonts.mydomain.eu/{fontstack}/{range}.pbf",
  "layers": [...]
}
@acalcutt
Copy link
Collaborator

have you tried if v4.6.1 fixes it?

@acalcutt
Copy link
Collaborator

I just tested your style and it looks like it is the same in 4.6.1 . I didn't change anything specific to glyphs and sprites, so I will have to try and track it down.

@alex-kowalczyk
Copy link
Contributor Author

@acalcutt thanks for your response. Looking at the changelog, this 4.5.2 change might be related:
"chore: cleanup useless decodeURIComponent() calls"
https://github.com/maptiler/tileserver-gl/pull/1002/files

@acalcutt
Copy link
Collaborator

acalcutt commented Oct 20, 2023

I does seem like
https://github.com/liberty-rider/tileserver-gl/blob/869ab0489cb7b5396b46c051deda6afd15f38808/src/serve_rendered.js#L26
partially causes the issue.

With that included the style json returns
image

But with the old tester string it returns
image

I do have to wonder though, did raster maps work at all for you before with this style? There is also this other code on the rendering side that always seems to append path
https://github.com/maptiler/tileserver-gl/blob/master/src/serve_rendered.js#L1237-L1260
which seems like it would have broken rendering for this style, and that has been like that for a while

EDIT: nevermind on the second location, that would only apply if the string started with sprites:// or glyphs:// I think

@alex-kowalczyk
Copy link
Contributor Author

I used vector tiles only. Do you mean server-side rendered rasters of my vectors?
Just tried to access "raster" variant on 4.5.1 through tileserver UI and yes, they work fine (fonts and glyphs correctly rendered on them)

@acalcutt
Copy link
Collaborator

Ya, the rendering part I am talking about makes the images on the index page next to your style, and also the images for the raster page you are talking about, to the right of your style on the index page.

When I revert the HttpTester string the vector tiles work again and and the style looks correct.

However when it tries to render it looks like it uses https://github.com/maptiler/tileserver-gl/blob/master/src/serve_rendered.js#L1237-L1260 and maplibre-native gets an error it adds in the path.

mlgl: {
  class: 'Style',
  severity: 'ERROR',
  text: "Failed to load sprite: ENOENT: no such file or directory, open 'C:\\Users\\Andrew\\Documents\\GitHub\\tileserver-gl-wdb\\config\\https:\\tiles.wifidb.net\\styles\\WDB_DARK_MATTER\\sprite.png'"
}

@acalcutt
Copy link
Collaborator

I missed that the http testing code was actually in two places

https://github.com/liberty-rider/tileserver-gl/blob/869ab0489cb7b5396b46c051deda6afd15f38808/src/serve_style.js#L12
https://github.com/liberty-rider/tileserver-gl/blob/869ab0489cb7b5396b46c051deda6afd15f38808/src/serve_rendered.js#L26

Any chance you can put in a PR to revert these back to
const httpTester = /^(http(s)?:)?\/\//;

it will be easier for me to approve the change if someone else puts it in.

@alex-kowalczyk
Copy link
Contributor Author

Thanks! Will do the PR.

@acalcutt
Copy link
Collaborator

@Caerbannog , just an fyi. this broke in v4.5.2 with #1002

@acalcutt acalcutt changed the title 4.6.0 breaks URL-based "glyphs" and "sprites" (concats URLs with root paths?) 4.5.2 breaks URL-based "glyphs" and "sprites" (concats URLs with root paths?) Oct 20, 2023
@acalcutt acalcutt changed the title 4.5.2 breaks URL-based "glyphs" and "sprites" (concats URLs with root paths?) 4.5.2-4.6.1 breaks URL-based "glyphs" and "sprites" (concats URLs with root paths?) Oct 20, 2023
alex-kowalczyk added a commit to alex-kowalczyk/tileserver-gl that referenced this issue Oct 20, 2023
…ng of vector tiles

Root cause: modified regex in maptiler#1002 caused URLs to be broken.
Fixed by reverting previous regexes.

Tests:
 * Confirmed by building and running locally with formerly breaking config.json and style json.
 * Run tests via Dockerfile_test
@alex-kowalczyk
Copy link
Contributor Author

@acalcutt here goes the PR.

@acalcutt
Copy link
Collaborator

acalcutt commented Oct 20, 2023

Thanks for the PR. I'll merge it as soon at the tests finish and make a new release.

Just a side FYI, I don't think this sections in your config.json does anything.

  "sources": {
     "europe": {
        "url": "mbtiles://{europe}",
        "type": "vector"
     }
  },

that format would be used in your style, the mystyle.json fie, to reference (data -> europe) in config.json

acalcutt pushed a commit that referenced this issue Oct 20, 2023
…ctor tiles (#1026)

Root cause: modified regex in #1002 caused URLs to be broken.
Fixed by reverting previous regexes.

Tests:
 * Confirmed by building and running locally with formerly breaking config.json and style json.
 * Run tests via Dockerfile_test
@Caerbannog
Copy link
Contributor

Ouch, sorry for creating this bug. I ignored the ^ in the regex when I reasoned about it.

@acalcutt
Copy link
Collaborator

v4.6.2 has been released, so let me know if that fixes your issue.

@Caerbannog I was just glad it wasn't my PR this time...haha

@alex-kowalczyk
Copy link
Contributor Author

Just grabbed 4.6.2 docker image and tested with my jsons. Perfetto!
Thank you so much @acalcutt !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants