Page MenuHomePhabricator

Module CSS sometimes loaded after module JS is executed
Closed, ResolvedPublic

Description

This is caused by a bug in jQuery.Callbacks:

> cb = $.Callbacks()
> cb.add(function () { console.log('one'); cb.add( function () { console.log('two' ); } ); } );
> cb.fire()
one
two

What happens is:

  • execute() is called for module A
  • This calls addEmbeddedCSS( cssA, cbA ) where cssA is the CSS for module A, and cbA is a callback that is added to the CSS callback list
  • From a timeout, addEmbeddedCSS() flushes its buffer and fires the callback list, so cbA is called
  • cbA executes module A's JS
  • cbA calls handlePending(), which notices that module B (which depends on A) is now runnable
  • execute() is called for module B
  • This calls addEmbeddedCSS( cssB, cbB ) , and adds cbB to the CSS callback list
  • Once this stack rolls back up, we end up back in callbacks.fire(), which notices the newly added cbB callback and calls it immediately
  • cbB executes modules B's JS
  • From a timeout, addEmbeddedCSS() adds module B's CSS

Event Timeline

Catrope created this task.Jul 15 2015, 11:02 PM
Catrope raised the priority of this task from to Needs Triage.
Catrope updated the task description. (Show Details)
Catrope added subscribers: Catrope, Krinkle.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 15 2015, 11:02 PM
GOIII added a subscriber: GOIII.Jul 16 2015, 10:35 PM

Change 226036 had a related patch set uploaded (by Catrope):
mw.loader: Fix late loading of CSS in certain cases

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

Change 226036 merged by jenkins-bot:
mw.loader: Fix late loading of CSS in certain cases

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

Krinkle closed this task as Resolved.Aug 5 2015, 1:04 AM
Krinkle assigned this task to Catrope.
Krinkle triaged this task as Normal priority.
Krinkle moved this task from Inbox to Assigned on the MediaWiki-ResourceLoader board.
Krinkle moved this task from Inbox to Doing on the Performance-Team board.
Krinkle removed a project: Patch-For-Review.
Krinkle set Security to None.
Krinkle removed a subscriber: gerritbot.