Page MenuHomePhabricator

maps.wikimedia.org doesn't respect devicePixelRatio (Hi-DPI / Retina)
Closed, ResolvedPublic

Description

Maps shown via leaflet at maps.wikimedia.org don't respect devicePixelRatio, so always show low-resolution imagery that looks very blurry on a hi-DPI / 'Retina' display. It appears that higher-resolution imagery is available but not used.

Example: https://maps.wikimedia.org/#16/45.5018/-122.6712

One of the tiles: https://maps.wikimedia.org/osm-intl/16/10436/23444.png

Same tile rendered at 2x density, which should be used instead: https://maps.wikimedia.org/osm-intl/16/10436/23444@2x.png

Note that there seem to be only a few specific density levels supported. If I try an arbitrary @4x, I get this error message back from the tile server:

"This scaling is not allowed for this source. Allowed: 1.3,1.5,2,2.6,3"

So the client-side code will need to either hardcode this list or be able to query it from some kind of configuration or API, then bracket the actual DPR value to the available ones.

Event Timeline

brion raised the priority of this task from to Needs Triage.
brion updated the task description. (Show Details)
brion added a project: Maps.
brion subscribed.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Provisional patch, since 'git review' doesn't work on kartotherian repo:

maps.wikimedia.org is really a debug interface for the maps -- we could of course add the DPI detection there, but the same work will still have to be done on the client that uses it.

We could add the allowed scaling values into the https://maps.wikimedia.org/osm-intl/info.json

maps.wikimedia.org is really a debug interface for the maps -- we could of course add the DPI detection there, but the same work will still have to be done on the client that uses it.

We could add the allowed scaling values into the https://maps.wikimedia.org/osm-intl/info.json

Hmm, I wonder if it would be crazy to allow sending a scaling factor (from window.devicePixelRatio or native or whatever) as a query string parameter to that info.json and have it return a pre-bracketed value that's known to work?

Also, is it possible to have different available scaling levels depending on the tile source being used? That might make it trickier to expose the correct values.

Per @Yurik this project is using GitHub as primary, so resubmitted via a pull req: https://github.com/kartotherian/kartotherian/pull/13

i made some changed to @brion's patch, and deployed to the server, so i suspect we can close it.

Scaling factors are hardcoded for each source, but I simply picked the most common ones to reduce cache fragmentation. In theory, there could be a source that's pointless to scale, e.g. a raster source which presents the entire planet as a TIFF at zoom 5. When user asks for zoom 2, we give them a scaled down portion of that image. If they ask for scaling, we scale less for the same area (higher dpi). But if user asks for higher scale at zoom 5 (the max zoom), the raster there exists at 1:1, so we will waste bandwidth - we will scale the image without adding any data, something the client could have done itself.
All this requires advanced logic on the client, something to analyse the info.json and come up with the best downloading strategy.
I think we should write a simple js lib for that and host it as part of the maps service.

@brion, do you think it also makes sense to update the official tutorial at https://github.com/MaxSem/maps-demo ? We're running it at http://maps.beta.wmflabs.org for example.

Max, I have updated Brion's last patch, take a look in Kartotherian repo

So can I close this out as resolved, or should that wait for it to be working on http://maps.beta.wmflabs.org too?

brion claimed this task.