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 created this task.Sep 17 2015, 8:02 PM
brion raised the priority of this task from to Needs Triage.
brion updated the task description. (Show Details)
brion added a project: Maps.
brion added a subscriber: brion.
Restricted Application added a project: Discovery. · View Herald TranscriptSep 17 2015, 8:02 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

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

Yurik added a subscriber: Yurik.Sep 17 2015, 8:29 PM

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

brion added a comment.Sep 17 2015, 8:36 PM

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.

brion added a comment.Sep 17 2015, 8:48 PM

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.

MaxSem added a subscriber: MaxSem.Sep 18 2015, 9:21 PM

@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.

brion added a comment.Sep 18 2015, 9:29 PM

Yes that'd seem ideal. :D

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

brion added a comment.Sep 21 2015, 7:20 PM

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

Yurik added a comment.Sep 21 2015, 7:48 PM

I'm fine with closing it.

brion closed this task as Resolved.Sep 21 2015, 8:53 PM
brion claimed this task.
Deskana moved this task from Needs triage to Maps on the Discovery board.Sep 22 2015, 5:29 PM
Tfinc moved this task from Backlog to Done on the Maps-Sprint board.Oct 6 2015, 9:03 PM