openstreetmap / operations

OSMF Operations Working Group issue tracking
https://operations.osmfoundation.org/
98 stars 13 forks source link

Serve tiles over WebP or AVIF #902

Open grischard opened 1 year ago

grischard commented 1 year ago

95% of browsers support WebP, and 84% support avif. By serving our raster tiles over WebP and/or AVIF, we could reduce our bandwidth usage and speed up our maps without a noticeable loss in quality.

Since compatibility is so wide-spread, we should directly render WebP or AVIF tiles instead of PNG, and transcode the tiles to PNG on demand. I'm not sure exactly where in the stack this would happen?

As we would serve image formats depending on the client's support, we need to ensure our caching is done on 'Vary Accepts' headers, both for the CDN and the clients.

The old tile URL would be backwards compatible, but announcing this would be a good opportunity to encourage people to use https://tile.openstreetmap.org/z/x/y (see also #737)

Testing on:

Firefishy commented 1 year ago

Mapnik supports generating WebP natively.

grischard commented 1 year ago

https://github.com/mapnik/mapnik/wiki/Image-IO says webp is "experimental".

AVIF support is "future".

Can fastly auto-transcode webp to png?

colourgarden commented 1 year ago

Can fastly auto-transcode webp to png?

Yes - https://developer.fastly.com/reference/io/format/

pnorman commented 1 year ago

I would be reluctant to build something that relies on Fastly's closed-source components. Additionally, I would want to serve webp and transcode it to PNG, which would require mod_tile to support webp metatiles.

pnorman commented 12 months ago

I wouldn't mind moving to all webp - metatiles in webp, sliced into either png or webp tiles.

Looking at https://jpegxl.info/comparison.png, webp is considered better for lossless non-photographic, while avif is better for mixed photo/nonphoto, given what Netflix designed it for. Of course, that particular chart recommends JPEG XL since it's from the JPEG XL community site and has an agenda. JPEG XL isn't an option with virtually no support among browsers.

But we'd still need to produce PNG tiles for the significant number of PNG-only users that aren't browsers.

I don't see this being worth the effort, given the state of mod_tile and other priorities for developing the standard layer

grischard commented 12 months ago

If the mod_tile route is a dead end, let's see about using Fastly's Image Optimizer? We prefer open source, of course, but only if it's possible. Apparently, Image Optimizer is an extra service - can we ask them if they'd be willing to enable it on our account?

Even if we go all-out on vector tiles, I expect that we will still be serving raster tiles for a few years.

hummeltech commented 6 months ago

mod_tile also now supports WebP tiles/metatiles since v0.7.0, although I am not sure how experimental it still is on Mapnik's end.

https://github.com/openstreetmap/mod_tile/pull/318