Page MenuHomePhabricator

Reduce number of bucketsizes for MediaViewer
Closed, ResolvedPublic2 Estimated Story Points

Description

Currently mediaview uses [ 320, 800, 1024, 1280, 1920, 2560, 2880 ]

This creates many thumbnail options, generating separate files for different users including for preloaded thumbnails.
This is a bit of a waste. Time to generate the thumbnail is a much more critical metric than download bytes, 14 years after this was originally implemented.

Browsers are much better at scaling and we probably just don't need this many bucket sizes.

Proposal is to set it to [ 500, 960, 1280, 2560 ] (updated from discussion, and again after confirming wgThumbnailSteps prefers 500 over 400)
We can do this via the config variable wgMediaViewerThumbnailBucketSizes after T269987 was deployed.

  • Note: Previously this got reverted because of the ways arrays in mediawiki/config operate - it was merging arrays rather than otherwirting. Make sure you update wgMediaViewerThumbnailBucketSizes to use merge_strategy provide_default (by default arrays are merged via + operator). Alternatively define the config in CommonSettings.php rather than InitialiseSettings.php
  • Agree on bucket values: [400, 960, 1280, 2560]
  • deploy to group0 and pilot wikis - config patch
  • deploy to group1
  • deploy to group2
  • reconciled the smallest size with wgThumbnailSteps by changing 400 to 500

QA notes

Test procedure once deployed to group0:

(Have pushed to all groups in production by now and updated to final sizes.)

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

While I largely agree with the "Time to generate the thumbnail is a much more critical metric than download bytes" statement, having recently been out traveling with poor reception, I don't think we can totally discount the latter either. I have absolutely no idea how many such small-sized screens remain in use nowadays, but https://gs.statcounter.com/screen-resolution-stats seems to suggest it's not a negligible number.

I think thumbnail widths in $wgThumbnailSteps and $wgThumbLimits can be expected to be readily available, so I don't see harm in using (some of) those values in addition to some larger ones (where I do agree we can probably trim the list much more aggressively)

Jdlrobson-WMF lowered the priority of this task from High to Medium.Aug 27 2025, 4:27 PM
HSwan-WMF renamed this task from [SPIKE] Reduce number of bucketsizes for MediaViewer to Reduce number of bucketsizes for MediaViewer.Oct 8 2025, 4:50 PM
HSwan-WMF updated the task description. (Show Details)
HSwan-WMF set the point value for this task to 2.

FYI: I would suggest [400, 960, 1280, 2560] - the lower 2 are already standard sizes (wgThumbLimits & wgThumbnailSteps) and, based on statcounter, would cover at least 20% (and those are likely the ones where the amount of bytes remain relatively important as well)

I agree with @matthiasmullie's idea. This can help with the infrastructure a lot.

No problem from my side. We still have to update the merge strategy for MediaViewerThumbnailBucketSizes first (why it was reverted initially).

Change #1196512 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/extensions/MultimediaViewer@master] Configuration: Use provide_default merge strategy for MediaViewerThumbnailBucketSizes

https://gerrit.wikimedia.org/r/1196512

Change #1196512 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Configuration: Use provide_default merge strategy for MediaViewerThumbnailBucketSizes

https://gerrit.wikimedia.org/r/1196512

Change #1204700 had a related patch set uploaded (by Bvibber; author: Bvibber):

[operations/mediawiki-config@master] Reduce number of bucketsizes for MediaViewer (group0)

https://gerrit.wikimedia.org/r/1204700

bvibber updated the task description. (Show Details)

Updated config patch with [400, 960, 1280, 256] on beta & group0 scheduled for this afternoon :D

https://schedule-deployment.toolforge.org/window/1763067600

Change #1204700 merged by jenkins-bot:

[operations/mediawiki-config@master] Reduce number of bucketsizes for MediaViewer (labs, group0)

https://gerrit.wikimedia.org/r/1204700

Mentioned in SAL (#wikimedia-operations) [2025-11-13T21:13:15Z] <bvibber@deploy2002> Started scap sync-world: Backport for [[gerrit:1204928|StickyHeaders: scroll-margin-top fixes (T409349)]], [[gerrit:1204700|Reduce number of bucketsizes for MediaViewer (labs, group0) (T372165)]], [[gerrit:1204957|Editcheck: flag suggestions when logging actions (T407170)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-13T21:15:26Z] <bvibber@deploy2002> bvibber, kemayo: Backport for [[gerrit:1204928|StickyHeaders: scroll-margin-top fixes (T409349)]], [[gerrit:1204700|Reduce number of bucketsizes for MediaViewer (labs, group0) (T372165)]], [[gerrit:1204957|Editcheck: flag suggestions when logging actions (T407170)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-13T21:22:13Z] <bvibber@deploy2002> Finished scap sync-world: Backport for [[gerrit:1204928|StickyHeaders: scroll-margin-top fixes (T409349)]], [[gerrit:1204700|Reduce number of bucketsizes for MediaViewer (labs, group0) (T372165)]], [[gerrit:1204957|Editcheck: flag suggestions when logging actions (T407170)]] (duration: 08m 58s)

Update config with [400, 960, 1280, 2560] is now LIVE on beta & production group0 (includes test.wikipedia.org). If nothing explodes I'll roll it out to group1 and group2 next week and we can close.

Change #1206433 had a related patch set uploaded (by Bvibber; author: Bvibber):

[operations/mediawiki-config@master] Reduced MediaViewer bucket sizes list to group1

https://gerrit.wikimedia.org/r/1206433

Change #1206433 merged by jenkins-bot:

[operations/mediawiki-config@master] Reduced MediaViewer bucket sizes list to group1

https://gerrit.wikimedia.org/r/1206433

Mentioned in SAL (#wikimedia-operations) [2025-11-17T21:04:54Z] <bvibber@deploy2002> Started scap sync-world: Backport for [[gerrit:1206433|Reduced MediaViewer bucket sizes list to group1 (T372165)]], [[gerrit:1206395|Release CampaignEvents extension to all remaining wikis (T409760)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-17T21:09:56Z] <bvibber@deploy2002> bvibber, cmelo: Backport for [[gerrit:1206433|Reduced MediaViewer bucket sizes list to group1 (T372165)]], [[gerrit:1206395|Release CampaignEvents extension to all remaining wikis (T409760)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-17T21:17:36Z] <bvibber@deploy2002> Finished scap sync-world: Backport for [[gerrit:1206433|Reduced MediaViewer bucket sizes list to group1 (T372165)]], [[gerrit:1206395|Release CampaignEvents extension to all remaining wikis (T409760)]] (duration: 12m 43s)

Change #1206924 had a related patch set uploaded (by Bvibber; author: Bvibber):

[operations/mediawiki-config@master] MediaViewer buckets reduction to all groups

https://gerrit.wikimedia.org/r/1206924

Change #1206924 merged by jenkins-bot:

[operations/mediawiki-config@master] MediaViewer buckets reduction to all groups

https://gerrit.wikimedia.org/r/1206924

Mentioned in SAL (#wikimedia-operations) [2025-11-18T21:04:26Z] <bvibber@deploy2002> Started scap sync-world: Backport for [[gerrit:1206924|MediaViewer buckets reduction to all groups (T372165)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-18T21:08:49Z] <bvibber@deploy2002> bvibber: Backport for [[gerrit:1206924|MediaViewer buckets reduction to all groups (T372165)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-18T21:13:43Z] <bvibber@deploy2002> Finished scap sync-world: Backport for [[gerrit:1206924|MediaViewer buckets reduction to all groups (T372165)]] (duration: 09m 17s)

Can we maybe adjust the set of sizes in the light of what is already in common use (cf T410304) - e.g. 400 is currently very uncommon compared to 500 or 330, so if we're trying to rationalise, it'd make sense to go with one of those rather than 400.

Or maybe the not-canonical-but-quite-popular 480.

It seems that something is pushing the 400 bucket up to 500 anyway -- all the other sizes are going through as I expect, and the config var is fine. Let's file a followup task to a) figure out why it's doing that and b) if we'd prefer 480 or 500 anyway, tweak it as a followup.

Ok we can follow that up in T410556: figure out why it's coming up as 500 instead of the configured 400, then decide whether to bump the config to 500, leave it at 400, or chose 480 based on expected usage and the presence of the constraint.

Should be safe to close this task out as the updated config vars _are_ correctly sent through now, and the 960/1280/2560 part is more performance-critical on desktop. (The smallest size will become more important when we merge mobile and desktop media viewers someday!)

Change #1207273 had a related patch set uploaded (by Bvibber; author: Bvibber):

[operations/mediawiki-config@master] Fix wgMediaViewerThumbnailBucketSizes to match wgThumbnailSteps

https://gerrit.wikimedia.org/r/1207273

Above patch is to reconcile wgMediaViewerThumbnailBucketSizes with wgThumbnailSteps by bumping 400 to 500. This will make behavior consistent for MultimediaViewer whether it can "guess" resized URLs based on a source thumbnail or not. Follow-up work to spike T410556.

Can we maybe adjust the set of sizes in the light of what is already in common use (cf T410304) - e.g. 400 is currently very uncommon compared to 500 or 330, so if we're trying to rationalise, it'd make sense to go with one of those rather than 400.

Due to T360589 they already switch to the thumbnail steps that's why they are being served as 500px while showing 400px in the list. T410556 will fix the text lying to the user but it's not a different size. Most of the sizes listed in T408715 are similar and have no affect on url to the thumbnail (what cdn/swift/thumbor sees and cares about) but the visual size of the image.

Or maybe the not-canonical-but-quite-popular 480.

The 500px was chosen in thumbnail steps intentionally. It's double 250px which is the requested default and we serve 500 as 2x version for retina screens and as results many mobiles actually load 500px for images instead.

Can we maybe adjust the set of sizes in the light of what is already in common use (cf T410304) - e.g. 400 is currently very uncommon compared to 500 or 330, so if we're trying to rationalise, it'd make sense to go with one of those rather than 400.

Due to T360589 they already switch to the thumbnail steps that's why they are being served as 500px while showing 400px in the list. T410556 will fix the text lying to the user but it's not a different size. Most of the sizes listed in T408715 are similar and have no affect on url to the thumbnail (what cdn/swift/thumbor sees and cares about) but the visual size of the image.

I don't think that's correct - I spent a little while looking at today's commons POTD in Media Viewer, and if I made my browser window quite small and then used "Open Image in New Tab", I got to https://upload.wikimedia.org/wikipedia/commons/thumb/8/84/Oilshale_mine_01.jpg/400px-Oilshale_mine_01.jpg?20211214185244 which is a 400px image, not one of the 8 $wgThumbnailSteps. Or am I misunderstanding you?

You are right that the proffered sizes in the "Other resolutions" list are incorrect (e.g that the 640x437 one is in fact 960), but those are ImageLimits not wgMediaViewerThumbnailBucketSizes.

(to be clear, the testwiki link above does result in 500 at smallest, not 400 as I get with commons. I don't know if that's expected)

Change #1207273 merged by jenkins-bot:

[operations/mediawiki-config@master] Fix wgMediaViewerThumbnailBucketSizes to match wgThumbnailSteps

https://gerrit.wikimedia.org/r/1207273

Mentioned in SAL (#wikimedia-operations) [2025-11-20T21:03:00Z] <bvibber@deploy2002> Started scap sync-world: Backport for [[gerrit:1207273|Fix wgMediaViewerThumbnailBucketSizes to match wgThumbnailSteps (T372165)]], [[gerrit:1207865|Undeploy the WikimediaEditorTasks extension (T376954)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-20T21:29:10Z] <bvibber@deploy2002> bvibber, jforrester: Backport for [[gerrit:1207273|Fix wgMediaViewerThumbnailBucketSizes to match wgThumbnailSteps (T372165)]], [[gerrit:1207865|Undeploy the WikimediaEditorTasks extension (T376954)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Change #1208003 had a related patch set uploaded (by Bvibber; author: Bvibber):

[operations/mediawiki-config@master] Fix wgMediaViewerThumbnailBucketSizes on prod

https://gerrit.wikimedia.org/r/1208003

Mentioned in SAL (#wikimedia-operations) [2025-11-20T21:42:55Z] <bvibber@deploy2002> Finished scap sync-world: Backport for [[gerrit:1207273|Fix wgMediaViewerThumbnailBucketSizes to match wgThumbnailSteps (T372165)]], [[gerrit:1207865|Undeploy the WikimediaEditorTasks extension (T376954)]] (duration: 39m 55s)

Change #1208003 merged by jenkins-bot:

[operations/mediawiki-config@master] Fix wgMediaViewerThumbnailBucketSizes on prod

https://gerrit.wikimedia.org/r/1208003

Mentioned in SAL (#wikimedia-operations) [2025-11-20T21:48:40Z] <reedy@deploy2002> Started scap sync-world: Backport for [[gerrit:1208003|Fix wgMediaViewerThumbnailBucketSizes on prod (T372165)]], [[gerrit:1208005|AccountRecovery: Allow temp users to access Special:AccountRecovery]]

Mentioned in SAL (#wikimedia-operations) [2025-11-20T21:54:06Z] <reedy@deploy2002> bvibber, reedy: Backport for [[gerrit:1208003|Fix wgMediaViewerThumbnailBucketSizes on prod (T372165)]], [[gerrit:1208005|AccountRecovery: Allow temp users to access Special:AccountRecovery]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-20T22:00:46Z] <reedy@deploy2002> Finished scap sync-world: Backport for [[gerrit:1208003|Fix wgMediaViewerThumbnailBucketSizes on prod (T372165)]], [[gerrit:1208005|AccountRecovery: Allow temp users to access Special:AccountRecovery]] (duration: 12m 06s)

bvibber updated the task description. (Show Details)

Ok the reconciliation with wgThumbnailSteps is complete: getting 500px is now officially Fine And Good as the smallest size on the QA test link :D

lwatson subscribed.

QA test passed for MediaViewer's thumbnail bucket sizes config, wgMediaViewerThumbnailBucketSizes.

  • Test on different viewport sizes.
  • Verify thumbnail bucket sizes: 500px, 960px, 1280px, 2560px.

deployed and DONE. followup work -> T410711