Page MenuHomePhabricator

TimedMediaHandler injects too many JavaScript configuration variables
Closed, ResolvedPublic

Description

JavaScript configuration variables that are added via ResourceLoaderGetConfigVars are inserted into the start-up module, which is on the critical path to loading page content. MwEmbedSupport uses this interface to inject the contents of two configuration files, MediaWikiSupport.config.php & MwEmbedSupport.config.php, which contain largely static configuration data that is MwEmbedSupport-specific, the loading of which could be limited to pages containing timed media, and deferred until DOMContentLoaded or later.

If the configuration variables truly are static, they can be hard-coded in a JavaScript file and included in the scripts array of the the MwEmbedSupport ResourceLoader module. If it is important for these values to be configurable via PHP, a custom ResourceLoader module class should be written. For an example of this technique, refer to includes/ResourceLoaderULSJsonMessageModule.php in the UniversalLanguageSelector extension.

List and values in Wikimedia production as of 2018-08-17:

AjaxRequestTimeout: 30
EmbedPLayer.IFramePlayer.DomainWhiteList: "*"
EmbedPlayer.AttributionButton: {title: "Kaltura html5 video library", href: "http://www.kaltura.com", class: "kaltura-icon", style: {…}, iconurl: false}
EmbedPlayer.BlackPixel: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkqAcAAIUAgUW0RjgAAAAASUVORK5CYII="
EmbedPlayer.CodecPreference: ["vp9", "webm", "h264", "ogg", "mp3", "ogvjs"]
EmbedPlayer.ControlsHeight: 31
EmbedPlayer.DefaultSize: "400x300"
EmbedPlayer.DefaultSkin: "mvpcf"
EmbedPlayer.DisableVideoTagSupport: false
EmbedPlayer.EnableFlavorSelector: false
EmbedPlayer.EnableFullscreen: true
EmbedPlayer.EnableIframeApi: true
EmbedPlayer.EnableIpadHTMLControls: true
EmbedPlayer.EnableIpadNativeFullscreen: false
EmbedPlayer.EnableRightClick: true
EmbedPlayer.EnableTimeDisplay: true
EmbedPlayer.EnableURLTimeEncoding: "flash"
EmbedPlayer.EnableVolumeControl: true
EmbedPlayer.EnabledOptionsMenuItems: ["playerSelect", "download", "share", "aboutPlayerLibrary"]
EmbedPlayer.FirefoxLink: "http://www.mozilla.com/en-US/firefox/upgrade.html?from=mwEmbed"
EmbedPlayer.ForceLargeReplayButton: false
EmbedPlayer.FullScreenZIndex: 999998
EmbedPlayer.FullscreenTip: true
EmbedPlayer.KalturaAttribution: true
EmbedPlayer.LibraryPage: "http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library"
EmbedPlayer.MonitorRate: 250
EmbedPlayer.NativeControls: false
EmbedPlayer.NativeControlsMobileSafari: true
EmbedPlayer.NewWindowFullscreen: false
EmbedPlayer.NotPlayableDownloadLink: true
EmbedPlayer.OverlayControls: true
EmbedPlayer.PageDomainIframe: true
EmbedPlayer.ReplaceSources: null
EmbedPlayer.RewriteSelector: "video,audio,playlist"
EmbedPlayer.ShareEmbedMode: "iframe"
EmbedPlayer.ShowNativeWarning: true
EmbedPlayer.ShowPlayerAlerts: true
EmbedPlayer.SkinList: ["mvpcf", "kskin"]
EmbedPlayer.TimeDisplayWidth: 85
EmbedPlayer.UseFlashOnAndroid: false
EmbedPlayer.WaitForMeta: true
EmbedPlayer.WebKitPlaysInline: false
EmbedPlayer.iPhoneShowHTMLPlayScreen: true
MediaWiki.DefaultProvider: "local"
MediaWiki.ApiProviders: { commons: { url: "//commons.wikimedia.beta.wmflabs.org/w/api.php" } }
MediaWiki.ApiPostActions: [ "login", "purge", "rollback", "delete", "undelete", "protect", "block", "unblock", "move", "edit", "upload", "emailuser", "import", "userrights" ]
TimedText.BelowVideoBlackBoxHeight: 40
TimedText.BottomPadding: 10
TimedText.NeedsTranscriptCategory: "Videos needing subtitles"
TimedText.ShowRequestTranscript: false

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:24 AM
bzimport set Reference to bz58082.

mdale wrote:

Makese sense. We should include this in player v2 inclusion / refactor efforts.

Performance-Team, are you guys still interested in this ? Cause it should be a lot easier to do now probably.

@TheDJ It's a bit less critical now that the startup module is asynchronous. However it'd still be good to optimise as much as possible because while it no longer blocks rendering, it does still block any javascript execution (e.g. attaching event handlers, handling permalink hashes such as mediaviewer etc.)

@TheDJ Can you confirm that (most) these config vars will go away after videojs is adopted as default? If so, feel free to close this.
T100106: Replace Kaltura player with Video.js

@Krinkle it would, but since there is no timetable for when video.js will be available on wikimedia servers I dont feel comfortable closing this.

Wooooaaahhh. I wrote

Object.keys( mw.config.get() ).filter( v => v.startsWith( 'EmbedPLayer.' ) );

in the console to see how many keys there are, and was surprised when I only got one value in the array. Turns out that one of the keys is misspelled. See the capital L in PLayer?

In other words

Object.keys( mw.config.get() ).filter( v => v.startsWith( 'EmbedPLayer.' ) ).length;

gives 1 and

Object.keys( mw.config.get() ).filter( v => v.startsWith( 'EmbedPlayer.' ) ).length;

gives 45.

And, for completeness

{
	const regex = /EmbedPLayer\./i;
	Object.keys( mw.config.get() ).filter( v => regex.test( v ) ).length;
}

gives 46, which means EmbedPLayer.IFramePlayer.DomainWhiteList is the only key with any capitalization error in that part of the name (that is, before the first dot).

Change 454345 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/TimedMediaHandler@master] Drop or inline some pointless config options

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

Change 454345 merged by jenkins-bot:
[mediawiki/extensions/TimedMediaHandler@master] Drop or inline some pointless config options

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

Krinkle renamed this task from MwEmbedSupport injects too many JavaScript configuration variables to TimedMediaHandler injects too many JavaScript configuration variables.Sep 26 2018, 2:08 AM
Krinkle lowered the priority of this task from Medium to Low.Mar 19 2019, 3:09 PM

Change 723200 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/TimedMediaHandler@master] Drop some unused MwEmbedModuleConfig values

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

Change 723200 merged by jenkins-bot:

[mediawiki/extensions/TimedMediaHandler@master] Drop some unused MwEmbedModuleConfig values

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

I'll take a look at this in more detail and see which are unlikely to be changed

Change 724108 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/extensions/TimedMediaHandler@master] JavaScript: use packageFiles for wgParserEnableLegacyMediaDOM

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

Change 724108 merged by jenkins-bot:

[mediawiki/extensions/TimedMediaHandler@master] JavaScript: use packageFiles for wgParserEnableLegacyMediaDOM

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