Page MenuHomePhabricator

Browser hangs up on huge galleries
Closed, ResolvedPublic

Description

As I can confirm a report on Commons (https://commons.wikimedia.org/wiki/Commons:Village_pump#Time-outs_loading_user_pages)
Firefox crashes on this pages (I looked in the browser log and it seems bad jQuery performance). I also can confirm that this user-pages in the past (one year or more) had not this problem.

The given example gallery pages are:

  1. https://commons.wikimedia.org/wiki/User:Glasshouse
  2. https://commons.wikimedia.org/wiki/User:SajoR
  3. https://commons.wikimedia.org/wiki/User:Heralder

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 31 2016, 12:29 PM
Perhelion updated the task description. (Show Details)

Firefox 47 on Fedora 24 only hangs here for a while, showing "Warning: Unresponsive script" popups and increased memory usage under top.
I cannot reproduce any crash.

@Perhelion: Did you report this issue to Mozilla's bugtracker? See the steps on http://support.mozilla.com/kb/Firefox%20crashes for more information, especially "Get help fixing this crash". Link welcome to your report. :)

Also, could you clarify what should or could be done on the Wikimedia side, as this was reported in Wikimedia Phabricator?

Also, could you clarify what should or could be done on the Wikimedia side, as this was reported in Wikimedia Phabricator?

Well it could be a problem with some script (either user or from core) that may need to be optimized for the case of large galleries.

matmarex added a subscriber: matmarex.

Looks like a problem with MultimediaViewer, which does some stupidly expensive jQuery searches when setting itself up. (Or rather, it does fairly normal jQuery searches, but ones that use some jQuery-specific features and can't be optimized by the browser; and when you do a thousand of them, they become stupidly expensive.)

You can click the "Debug script" button to identify it as the source:

Firefox's debugger interface seems intentionally designed to make it as difficult to use as possible, but you can luckily just right-click as shown in the screenshot and "Copy":

Sizzle@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:12:228
Sizzle</Sizzle.selectors.pseudos.has</<@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:25:828
elementMatcher/<@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:30:911
matcherFromGroupMatchers/superMatcher@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:34:663
Sizzle</Sizzle.select@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:36:877
Sizzle@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:12:280
Sizzle</Sizzle.matchesSelector@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:19:575
.closest@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:42:460
MMVB.findCaption@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=ext.centralNotice.choiceData,display,geoIP,impressionDiet,kvStore,kvStoreMaintenance,startUp|ext.centralauth.ForeignApi|ext.echo.api,init|ext.eventLogging,navigationTiming,wikimediaEvents|ext.eventLogging.subscriber|ext.gadget.AjaxQuickDelete,Cat-a-lot,CollapsibleTemplates,CropTool,ExtraTabs2,GoogleImages,HotCat,ImprovedUploadForm,LanguageSelect,Long-Image-Names-in-Categories,QuickDelete,RenameLink,RotateLink,Slideshow,Stockphoto,ThumbnailPurger,Tineye,UploadWizard,WatchlistNotice,WhatIsThat,WikiMiniAtlas,ZoomViewer,edittop,fastcci,libCommons,libJQuery,libUtil|ext.uls.eventlogger,pt|ext.visualEditor.targetLoader|ext.wikiLove.defaultOptions,init,startup|ext.wikimediaEvents.loggedin|jquery.checkboxShiftClick,getAttrs,highlightText,localize,makeCollapsible,mw-jump,placeholder,suggestions|mediawiki.ForeignApi,searchSuggest,storage,toc|mediawiki.ForeignApi.core|mediawiki.api.watch|mediawiki.page.ready|mediawiki.page.watch.ajax|mediawiki.ui.button,icon|mmv.bootstrap|mmv.bootstrap.autostart|oojs,site|schema.NavigationTiming,SaveTiming,UniversalLanguageSelector&skin=vector&version=1ftkso4:483:118
MMVB.processThumb@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=ext.centralNotice.choiceData,display,geoIP,impressionDiet,kvStore,kvStoreMaintenance,startUp|ext.centralauth.ForeignApi|ext.echo.api,init|ext.eventLogging,navigationTiming,wikimediaEvents|ext.eventLogging.subscriber|ext.gadget.AjaxQuickDelete,Cat-a-lot,CollapsibleTemplates,CropTool,ExtraTabs2,GoogleImages,HotCat,ImprovedUploadForm,LanguageSelect,Long-Image-Names-in-Categories,QuickDelete,RenameLink,RotateLink,Slideshow,Stockphoto,ThumbnailPurger,Tineye,UploadWizard,WatchlistNotice,WhatIsThat,WikiMiniAtlas,ZoomViewer,edittop,fastcci,libCommons,libJQuery,libUtil|ext.uls.eventlogger,pt|ext.visualEditor.targetLoader|ext.wikiLove.defaultOptions,init,startup|ext.wikimediaEvents.loggedin|jquery.checkboxShiftClick,getAttrs,highlightText,localize,makeCollapsible,mw-jump,placeholder,suggestions|mediawiki.ForeignApi,searchSuggest,storage,toc|mediawiki.ForeignApi.core|mediawiki.api.watch|mediawiki.page.ready|mediawiki.page.watch.ajax|mediawiki.ui.button,icon|mmv.bootstrap|mmv.bootstrap.autostart|oojs,site|schema.NavigationTiming,SaveTiming,UniversalLanguageSelector&skin=vector&version=1ftkso4:481:283
MMVB.processThumbs/<@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=ext.centralNotice.choiceData,display,geoIP,impressionDiet,kvStore,kvStoreMaintenance,startUp|ext.centralauth.ForeignApi|ext.echo.api,init|ext.eventLogging,navigationTiming,wikimediaEvents|ext.eventLogging.subscriber|ext.gadget.AjaxQuickDelete,Cat-a-lot,CollapsibleTemplates,CropTool,ExtraTabs2,GoogleImages,HotCat,ImprovedUploadForm,LanguageSelect,Long-Image-Names-in-Categories,QuickDelete,RenameLink,RotateLink,Slideshow,Stockphoto,ThumbnailPurger,Tineye,UploadWizard,WatchlistNotice,WhatIsThat,WikiMiniAtlas,ZoomViewer,edittop,fastcci,libCommons,libJQuery,libUtil|ext.uls.eventlogger,pt|ext.visualEditor.targetLoader|ext.wikiLove.defaultOptions,init,startup|ext.wikimediaEvents.loggedin|jquery.checkboxShiftClick,getAttrs,highlightText,localize,makeCollapsible,mw-jump,placeholder,suggestions|mediawiki.ForeignApi,searchSuggest,storage,toc|mediawiki.ForeignApi.core|mediawiki.api.watch|mediawiki.page.ready|mediawiki.page.watch.ajax|mediawiki.ui.button,icon|mmv.bootstrap|mmv.bootstrap.autostart|oojs,site|schema.NavigationTiming,SaveTiming,UniversalLanguageSelector&skin=vector&version=1ftkso4:480:141
.each@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:5:225
jQuery.prototype.each@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:2:214
MMVB.processThumbs@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=ext.centralNotice.choiceData,display,geoIP,impressionDiet,kvStore,kvStoreMaintenance,startUp|ext.centralauth.ForeignApi|ext.echo.api,init|ext.eventLogging,navigationTiming,wikimediaEvents|ext.eventLogging.subscriber|ext.gadget.AjaxQuickDelete,Cat-a-lot,CollapsibleTemplates,CropTool,ExtraTabs2,GoogleImages,HotCat,ImprovedUploadForm,LanguageSelect,Long-Image-Names-in-Categories,QuickDelete,RenameLink,RotateLink,Slideshow,Stockphoto,ThumbnailPurger,Tineye,UploadWizard,WatchlistNotice,WhatIsThat,WikiMiniAtlas,ZoomViewer,edittop,fastcci,libCommons,libJQuery,libUtil|ext.uls.eventlogger,pt|ext.visualEditor.targetLoader|ext.wikiLove.defaultOptions,init,startup|ext.wikimediaEvents.loggedin|jquery.checkboxShiftClick,getAttrs,highlightText,localize,makeCollapsible,mw-jump,placeholder,suggestions|mediawiki.ForeignApi,searchSuggest,storage,toc|mediawiki.ForeignApi.core|mediawiki.api.watch|mediawiki.page.ready|mediawiki.page.watch.ajax|mediawiki.ui.button,icon|mmv.bootstrap|mmv.bootstrap.autostart|oojs,site|schema.NavigationTiming,SaveTiming,UniversalLanguageSelector&skin=vector&version=1ftkso4:480:105
.proxy/proxy@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:6:826
jQuery.Callbacks/fire@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:45:103
jQuery.Callbacks/self.fireWith@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:46:430
mw.hook/<.fire@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:174:876
(anonymous)@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=Spinner|ext.centralauth.centralautologin.clearcookie|ext.uls.init,interface,preferences,webfonts|ext.visualEditor.desktopArticleTarget.init|ext.visualEditor.supportCheck,track,ve|jquery.byteLength,cookie,embedPlayer,loadingSpinner,mwEmbedUtil,tabIndex,throttle-debounce,triggerQueueCallback|jquery.uls.data|mediawiki.Title,Uri,api,cldr,cookie,jqueryMsg,language,template,user|mediawiki.action.view.postEdit|mediawiki.api.options,user|mediawiki.language.data,init|mediawiki.libs.pluralruleparser|mediawiki.page.startup|mediawiki.template.regexp|mmv.head|mw.EmbedPlayer.loader|mw.MediaWikiPlayer.loader|mw.MwEmbedSupport,PopUpMediaTransform|mw.MwEmbedSupport.style|mw.PopUpMediaTransform.styles|mw.TimedText.loader|skins.vector.js|user.defaults&skin=vector&version=1tuzjzu:130:168
jQuery.Callbacks/fire@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:45:103
jQuery.Callbacks/self.fireWith@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:46:430
.ready@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:49:399
completed@https://commons.wikimedia.org/w/load.php?debug=false&lang=en&modules=jquery,mediawiki&only=scripts&skin=vector&version=05zc3z0:49:924

Sizzle is the library that handles jQuery queries. MMVB stands for "MultimediaViewer bootstrap". The problematic piece of code is:

	MMVB.findCaption = function ( $thumbContain, $link ) {
		var $thumbCaption;

		if ( $thumbContain.length ) {
			// try to find closest caption to the image
			$thumbCaption = $link.closest( ':has(> .thumbcaption)', $thumbContain )
				.find( '> .thumbcaption' )
				.clone();

Queries with ':has' use jQuery's query engine, rather than the browser's. The innocuous $link.closest( ':has(> .thumbcaption)', $thumbContain ) (which finds the closest ancestor of $link that is within $thumbContain and also has a direct child that has the thumbcaption class) gets super expensive when you run it thousands of times. I'm not sure what exactly this does, but it looks like it could be done differently, this should not be a very expensive operation.

dr0ptp4kt triaged this task as Normal priority.Aug 1 2016, 4:58 PM
dr0ptp4kt moved this task from To Triage to Triaged but Future on the Readers-Web-Backlog board.

Change 302358 had a related patch set uploaded (by Gergő Tisza):
Speed up caption collection

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

Firefox 47 on Fedora 24 only hangs here for a while, showing "Warning: Unresponsive script" popups and increased memory usage under top.
I cannot reproduce any crash.

Yes I mean I chose the wrong word. I mean "hangs up".

Perhelion renamed this task from Browser crashes on huge galleries to Browser hangs up on huge galleries.Aug 1 2016, 10:59 PM
Restricted Application added subscribers: Poyekhali, Steinsplitter. · View Herald TranscriptAug 2 2016, 4:19 AM

Change 302358 merged by Bartosz Dziewoński:
Speed up caption collection

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

matmarex closed this task as Resolved.Aug 2 2016, 6:29 PM
matmarex assigned this task to Tgr.
Restricted Application added a project: Multimedia. · View Herald TranscriptMar 6 2018, 11:50 PM