Page MenuHomePhabricator

Investigate Page namespace 1.5x/2x image without zooming in
Open, Needs TriagePublic

Description

It appears that the Page namespace is loading a 1.5x/2x size image during load without the user actually having zoomed in. This could affect users who have a metered internet connection since we are effectively loading twice the amount of data without actually requiring any of the data.

This bug was reported by Ankry in the Wikisource-I mailing list.

Event Timeline

@Ankry Can send a screenshot of the networks tab (in your browser's developer tools) when you see this bug? I was able to reproduce it consistently on Windows (couldn't get it to load a bigger image in Linux) but based on a bit of looking around, the bigger image seems to be loaded via the HTML itself, not Openseadragon (not sure why that's the case).

@Soda do you have a HiDPI screen? If it's the case, I believe modern browsers will download and use the bigger image that is provided by the srcset attribute before the initialization of Openseadragon. Then Openseadragon is initialized and use the regular size image. It's what happens with my 4K screen configured with 2x scaling.

If it is indeed the case, a clean solution would be to initialize Openseadragon with the currently used image and not the regular size image. This information is exposed by browsers with the [currentSrc attribute](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/currentSrc).

BTW, it might also be useful to see what OSD thinks the pixel density is:

	mw.loader.using( 'ext.proofreadpage.openseadragon', function ( require ) {
		var OpenSeadragon = require( 'ext.proofreadpage.openseadragon' );
		console.log( 'OpenSeadragon pixel density: ' + OpenSeadragon.pixelDensityRatio );
	} );