Page MenuHomePhabricator

Consider adding one or more smaller pregenerated thumbnail buckets for mobile clients
Closed, InvalidPublic

Description

When an image is uploaded to Commons, thumbnails are pregenerated and cached for a specific set of widths, currently[1]:

[ 320, 640, 800, 1024, 1280, 1920 ]

The iOS app regularly rewrites thumbnail URLs downward in order to request smaller thumbnail sizes; depending on the sizes chosen they might be hitting cached thumbnails in many cases but certainly not all of them.

The Android app is currently using 320px even for the smallest icon-size thumbnails, which can certainly be improved, and I've opened a ticket to do just that. (T162633)

In an earlier ticket[2] @Gilles brought up the possibility of adding one or more smaller pregenerated thumbnail buckets in particular for the benefit of the mobile clients, and I'd like to follow up on that here. Is adding a smaller bucket (say, 120px) something that would be worthwhile in performance terms for both the server and clients? Personally, I would love to see this happen.

[1] https://phabricator.wikimedia.org/source/mediawiki-config/browse/master/wmf-config/InitialiseSettings.php;36a6da5b33f00f3bef38dbeeed19190f4582fcc9$18917

[2] T152163#2842875

Event Timeline

120 is the 5th most requested size and its average file size is obviously small. Interestingly it's also the highest on the list of cache misses. So yes, it would make absolute sense to add 120 to the pre-rendering list. Those thumbnails are already used a lot and would benefit from being pre-rendered, considering how their miss rate is high. As an already popular size, it's a good choice for mobile to leverage it. 220 is also worth considering, as its the size that gets the most absolute hits and is second for misses after 120.

Note that adding to the pre-rendering list only has a minimal performance effect in the short term, as it obviously only applies to images uploaded from that point on.

Alternatively, would it make sense to revisit cascaded scaling again? Scaling from say 640px to 120 might not be significantly more expensive than loading a pre-generated 120px thumb from storage.

If you're talking about chaining thumbnails server-side, that's difficult to do without affecting quality due to the conditional sharpening we apply to JPGs. An already sharpened intermediary size is unusable, as the end result would be over-sharpened. This issue is the reason why the last attempt at chaining thumbnails had to be pulled. To respect sharpening, we'd need to store unsharpened intermediary sizes as extra images, which is expensive storage-wise and rendering-wise.

We can do chaining for other file formats, than JPGs, but JPGs represent 86% of Commons content...