Phuedx has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/379532 )
Change subject: subscriber: Wait until browser idle before logging ...................................................................... subscriber: Wait until browser idle before logging If no additional ResourceLoader modules need to be loaded, then the subscriber module (ext.eventLogging.subscriber) may be executed after window.onload has fired. If this is the case, then the subscriber will never be subscribed. Subscribing the subscriber in an idle callback (via mw.requestIdleCallback) maintains the minimal impact of logging events on the loading of assets and avoids the Firefox 51+ issue of double-logging events due to window.onload firing twice under certain conditions (see T170018 and [0]). [0]: https://bugzilla.mozilla.org/show_bug.cgi?id=1379762 Bug: T175918 Change-Id: I4458c13194ba3962f67347726653d6354e4e41dc --- M modules/ext.eventLogging.subscriber.js 1 file changed, 7 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging refs/changes/32/379532/1 diff --git a/modules/ext.eventLogging.subscriber.js b/modules/ext.eventLogging.subscriber.js index 28ea1b7..be476c3 100644 --- a/modules/ext.eventLogging.subscriber.js +++ b/modules/ext.eventLogging.subscriber.js @@ -1,8 +1,8 @@ /*! - * Because subscribers to mw#track receive the full backlog of events - * matching the subscription, event processing can be safely deferred - * until the window's load event has fired. This keeps the impact of - * analytic instrumentation on page load times to a minimum. + * Because subscribers to mw#track receive the full backlog of events matching + * the subscription, event processing can be safely deferred until the browser + * is idle. This keeps the impact of analytic instrumentation on page load times + * to a minimum. * * @author Ori Livneh <[email protected]> */ @@ -87,13 +87,10 @@ }; - // Avoid the logging of duplicate events (T170018). - // - // The load event must only fire once. However, Firefox 51 introduced a - // bug that causes the event to fire again when returning from the - // "Back-Forward cache" (BFCache) under certain circumstances (see + // Using mw.requestIdleCallback also avoids the logging of duplicate events in + // Firefox 51+ when subscribing to the "load" event (see T170018 and // https://bugzilla.mozilla.org/show_bug.cgi?id=1379762). - $( window ).one( 'load', function () { + mw.requestIdleCallback( function () { mw.trackSubscribe( 'event.', handleTrackedEvent ); } ); -- To view, visit https://gerrit.wikimedia.org/r/379532 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4458c13194ba3962f67347726653d6354e4e41dc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/EventLogging Gerrit-Branch: master Gerrit-Owner: Phuedx <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
