Page MenuHomePhabricator

Make video.js's loading of ogv.js conditional
Closed, ResolvedPublic


Currently ogv.js is delivered to all video.js users. We probably want to load all that emscripten code conditionally however.


Related Gerrit Patches:
mediawiki/extensions/TimedMediaHandler : masterMade the dependency on videojs-ogvjs conditional

Event Timeline

TheDJ created this task.Apr 20 2016, 10:52 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 20 2016, 10:52 PM
brion added a subscriber: brion.Apr 23 2016, 7:44 PM

The emscripten-compiled code is all in dynamically-loaded modules since some versions back -- the codecs themselves are loaded in background Workers, the demuxer gets loaded into main context on demand. The core ogv.js file includes only the player logic and its direct dependencies (file streaming, audio output, yuv->rgb conversion).

But that's still a fair chunk of code there's no reason to load much of the time, so bonus points if we can load it conditionally as well.

Could do that through the MediaWiki+RL side by pulling up the pre-built videojs-ogvjs plugin (which bundles ogv.js inside via browserify IIRC) only after checking for relevant support, though that probably complicates initializing stuff.

Alternately the videojs-ogvjs plugin could load ogv.js as a static asset dynamically itself, as the current plugin for the mwembed stuff does.

brion added a comment.Apr 23 2016, 8:15 PM

(Double-checked and the videojs-ogvjs plugin is not bundling ogv.js itself, requires it to be preloaded. Misremembered. :D)

It looks like you can initialize a videojs plugin after a videojs instance has loaded, but I don't know if that'll work as expected with a tech plugin like this...

Best option might be something like this:

  • make a tmh-videojs-shim RL module, loaded as early as possible, that includes ogv-support.js and a list of enabled transcode derivative types. It'll check for native support (at least one video, and at least one audio format should be supported as 'probably' or 'maybe'!) and for ogv.js infrastructure support.
  • Have that module fire off RL for either just videojs, or videojs/ogvjs/videojs-ogvjs as a bundle.
  • Once both that load is complete and DOMReady has been reached, fire off instantiation of videojs players on top of the raw native ones.

On a large page, this might even give opportunity to background-load videojs and/or ogvjs while the page is still loading/parsing/rendering. :)

TheDJ moved this task from To sort to Player on the TimedMediaHandler board.Apr 26 2016, 5:41 PM

Change 316485 had a related patch set uploaded (by TheDJ):
Made the dependency on videojs-ogvjs conditional

TheDJ moved this task from Player to Doing on the TimedMediaHandler board.Oct 18 2016, 8:28 AM

Change 316485 merged by jenkins-bot:
Made the dependency on videojs-ogvjs conditional

TheDJ closed this task as Resolved.Oct 18 2016, 6:50 PM
TheDJ claimed this task.
TheDJ moved this task from Doing to Done on the TimedMediaHandler board.
TheDJ removed a project: Patch-For-Review.