Page MenuHomePhabricator

Consolidate code for MediaViewer across desktop and mobile
Open, MediumPublic

Description

Background

Desktop and mobile use different implementations for displaying a lightbox when images are clicked. There is lots of user value e.g. performance/functionality to consolidating these two experiences. The main reason we have separate experiences is that the desktop version is considerably bloated (see T77349 for more context). If we can reduce the size of this feature and simplify the code we can make use of the desktop across platforms.

The benefits of consolidating the two experience would be:

  • One less unmaintained extension in our deployed servers
  • More functionality to mobile users
  • better frontend performance for desktop users
  • The ability to use multimedia viewer across platforms for new media experiences.

Side by side comparison

Features

Additional desktop features: Has support for 3d images; has sharing functionality; additional information in summary; full screen behaviour; keyboard support

Performance

Last checked: October 15th 2024.

Bootstrap modules:

  • Desktop: (mmv.bootstrap): 4.8 kB
  • Mobile: loaded as part of mobile.startup (0.3kb)

Asynchronously loaded code:

  • Desktop: 25.2 kB (CSS = 6.4kb, messages = 1.8kb, mmv/ui/ = 8.7kb, models = 1.9kb, providers = 1.8kb)
  • Mobile: mobile.mediaViewer is 3.2KB (the majority of the code is generalized in mobile.startup or Codex)

Technology

  • Desktop built using Codex CSS-only components
  • Mobile uses non-standard MobileFrontend library that makes use of Codex CSS-only components. Benefits from generalized components such as an overlayManager and a templating engine.

Plan

  • 1) Simplify existing entry points:
  • Merge MultimediaViewer bootstrap modules. There is no need for them to live in separate modules and they bloat the size of our ResourceLoader startup module unnecessarily
  • 2) Reduce reliance on UI code and CSS:
  • Consolidate the behaviours for the caption - remove features from desktop - this appears to be the main contributor to the large code size.
  • Simplify error handling in mmv.ui.canvas.js to match less detailed solution in mobile.

Screenshot 2024-10-15 at 8.35.16 PM.png (3,028×988 px, 153 KB)

Screenshot 2024-10-15 at 8.36.12 PM.png (1,070×434 px, 28 KB)

  • Replace mw-mmv-dialog with cdx-dialog
  • Explore whether using Mustache for remaining HTML construction. would reduce code footprint.

Details

Reference
bz63504
Related Changes in Gerrit:

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
OpenNone
OpenNone
DuplicateNone
OpenNone
DeclinedNone
OpenJdlrobson
DuplicateNone
OpenNone
DeclinedNone
ResolvedTheDJ
DeclinedNone
ResolvedJdlrobson
Resolved• bmansurov
DeclinedNone
ResolvedJdlrobson
InvalidNone
Duplicate• Nirzar
OpenNone
ResolvedJdlrobson
DeclinedNone
ResolvedEsanders
ResolvedEsanders
Resolved• matmarex
Resolved• matmarex
Resolvedovasileva
ResolvedABorbaWMF
ResolvedNone
DuplicateNone
DuplicateNone
ResolvedJdlrobson
ResolvedTheDJ
ResolvedTheDJ
DeclinedNone
OpenNone
OpenNone
ResolvedBUG REPORTTheDJ
DuplicateNone
ResolvedJdlrobson
ResolvedBUG REPORTbvibber

Event Timeline

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

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

[mediawiki/extensions/MultimediaViewer@master] Remove the thumbnail blurring

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

Change #1032011 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Remove the thumbnail blurring

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

Jdlrobson updated the task description. (Show Details)

Change #1080832 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/SearchVue@master] mmv.bootstrap.autostart module was deprecated

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

Change #1080834 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] Mobile site should use the desktop media viewer

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

Change #1080422 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MobileFrontend@master] POC: Drop the mobile media viewer

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

Change #1080428 had a related patch set uploaded (by Jdlrobson; author: Simon04):

[mediawiki/extensions/MultimediaViewer@master] Move HtmlUtils from mmv.bootstrap to mmv module

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

Change #1080428 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Move HtmlUtils from mmv.bootstrap to mmv module

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

Change #1085682 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MultimediaViewer@master] POC: Showcase a simplistic version of MMV

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

Just an update here that I've been talking to a few people about what to do here. The sense I'm getting is that we likely want to keep the mobile media viewer as is as it presents a better experience for readers - most of the desktop features do not work nicely on mobile and are likely not as important to readers (who will click through to the file page if they want that information).

What I haven't worked out is how to get that state. A few options I am considering are:

  1. ) Adding a bunch of styling rules to the desktop version in a skinStyle to make it look more mobile like.
  2. Refactoring the existing desktop code so that we can have two versions of the media viewer in MultimediaViewer that share UI code - a simple version for mobile and a more complex for desktop. This would entail refactoring our classes and two modules - an advanced and simple media viewer making use of the refactored files.
  3. Complete rewrite of the desktop version in Vue
  4. Replacing the mobile version with the desktop version
  5. Keeping the status quo of two separate experiences.

Today I explored 2 and I spent some time building a proof of concept to see how much multimedia viewer could be simplified to render the existing mobile experience. The existing mobile experience could be achieved with 12.3 kB of code (compared with 25.3kb for desktop). I'm pretty sure that can be cut down further by refactoring / simplifying the calculation of thumbnail widths and heights.

Given there is no team actively maintaining and building out MMV right now, I would personally recommend working towards an approach where we would do:

  • 1 on the short term (but avoid if possible)
  • 2 on the medium term (through refactoring existing code paths)
  • 3 on the long term

Thoughts?

Change #1080832 merged by jenkins-bot:

[mediawiki/extensions/SearchVue@master] mmv.bootstrap.autostart module was deprecated

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

@simon04 would you be able to post a patch to remove mmv.bootstrap.autostart and mmv.head module ? If not, no worries, I can post that next week when I'm back from vacation and find someone to review :-).

Change #1098146 had a related patch set uploaded (by Simon04; author: Simon04):

[mediawiki/extensions/MultimediaViewer@master] Remove deprecated mmv.bootstrap.autostart and mmv.head

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

Change #1098146 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Remove deprecated mmv.bootstrap.autostart and mmv.head

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

Change #1085682 abandoned by Jdlrobson:

[mediawiki/extensions/MultimediaViewer@master] POC: Showcase a simplistic version of MMV

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

Change #1080834 abandoned by Jdlrobson:

[mediawiki/skins/MinervaNeue@master] POC: Mobile site should use the desktop media viewer

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

Change #1080422 abandoned by Jdlrobson:

[mediawiki/extensions/MobileFrontend@master] POC: Drop the mobile media viewer

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

For those who have not been keeping up, the mobile version is now being rebuilt in Vue.js as part of T417678: [Epic] Image Browsing: Feature parity for MMV beta viewer. Hopefully on the long term that can also replace the desktop version.

Change #1318788 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/extensions/MultimediaViewer@master] mmv.ui: Remove animated "metadata" invitation

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

Change #1318788 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] mmv.ui: Remove animated "metadata" invitation

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

Change #1324423 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[operations/mediawiki-config@master] POC: Enable new mobile media viewer on all wikis

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

Change #1324424 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MultimediaViewer@master] POC: Enable mobile media viewer for all wikis

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

Change #1324435 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MobileFrontend@master] Drop mobile media viewer in favor of Extension:MultimediaViewer

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

Change #1324437 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] Drop MobileFrontend multimedia viewer from Minerva

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

Change #1324423 abandoned by Jdlrobson:

[operations/mediawiki-config@master] POC: Enable new mobile media viewer on all wikis

Reason:

Done in https://gerrit.wikimedia.org/r/c/operations/mediawiki-config/+/1333816

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

Change #1324424 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Enable mobile media viewer for all wikis

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

Change #1324437 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Drop MobileFrontend multimedia viewer from Minerva

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

Change #1324435 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Drop mobile media viewer in favor of Extension:MultimediaViewer

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

Change #1345670 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MultimediaViewer@master] Allow use of Vue MMV beta on desktop

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

Change #1346818 had a related patch set uploaded (by Nick Battista; author: Nick Battista):

[mediawiki/extensions/MultimediaViewer@master] remove beta moniker from MMV mobile

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

Change #1348959 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MultimediaViewer@master] Drop FIXME now cache has cleared

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

Change #1345670 merged by jenkins-bot:

[mediawiki/extensions/MultimediaViewer@master] Allow use of Vue MMV beta on desktop

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

lwatson added subscribers: NBattista-WMF, lwatson.

The remaining patch drops the old mobile beta config and should only merge after the cache clears in 2 weeks from Thursday, Oct 8th.
Next step: In 2 weeks merge 1348959: Drop FIXME now cache has cleared

cc: @NBattista-WMF - tagging you since you are assigned reviewer on that remaining patch.

@Nux MultimediaViewer has a new Vue based media viewer that it displays on mobile currently.

With the latest change you can use it on desktop and that ensures your project is using same code on both mobile and desktop (config is $wgMediaViewerDesktopVue). The desktop version has more features currently so it possibly would need those features added before being used on desktop, but I guess whether it is good enough would vary on project.

Is this something your wiki(s) would be interested in trying out?