Bug 1489072 - Fix startup perf regression in pdf.js init. r=bdahl, a=RyanVM DEVEDITION_63_0b14_BUILD1 DEVEDITION_63_0b14_RELEASE FIREFOX_63_0b14_BUILD1 FIREFOX_63_0b14_RELEASE
authorKris Maglione <maglione.k@gmail.com>
Wed, 03 Oct 2018 13:09:40 -0700
changeset 490278 91955baf362b
parent 490277 b6b6ccb319ba
child 490279 32bc2353d656
push id9972
push userryanvm@gmail.com
push dateThu, 11 Oct 2018 20:01:18 +0000
treeherdermozilla-beta@91955baf362b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl, RyanVM
bugs1489072
milestone63.0
Bug 1489072 - Fix startup perf regression in pdf.js init. r=bdahl, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D7649
browser/components/nsBrowserGlue.js
browser/extensions/pdfjs/content/PdfJs.jsm
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -6,16 +6,18 @@ const XULNS = "http://www.mozilla.org/ke
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 ChromeUtils.defineModuleGetter(this, "ActorManagerParent",
                                "resource://gre/modules/ActorManagerParent.jsm");
 
+const PREF_PDFJS_ENABLED_CACHE_STATE = "pdfjs.enabledCache.state";
+
 let ACTORS = {
   AboutReader: {
     child: {
       module: "resource:///actors/AboutReaderChild.jsm",
       group: "browsers",
       events: {
         "AboutReaderContentLoaded": {wantUntrusted: true},
         "DOMContentLoaded": {},
@@ -1001,17 +1003,23 @@ BrowserGlue.prototype = {
     os.removeObserver(this, "shield-init-complete");
   },
 
   // runs on startup, before the first command line handler is invoked
   // (i.e. before the first window is opened)
   _beforeUIStartup: function BG__beforeUIStartup() {
     SessionStartup.init();
 
-    PdfJs.earlyInit();
+    if (Services.prefs.prefHasUserValue(PREF_PDFJS_ENABLED_CACHE_STATE)) {
+      Services.ppmm.sharedData.set(
+        "pdfjs.enabled",
+        Services.prefs.getBoolPref(PREF_PDFJS_ENABLED_CACHE_STATE));
+    } else {
+      PdfJs.earlyInit();
+    }
 
     // check if we're in safe mode
     if (Services.appinfo.inSafeMode) {
       Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",
                              "_blank", "chrome,centerscreen,modal,resizable=no", null);
     }
 
     // apply distribution customizations
--- a/browser/extensions/pdfjs/content/PdfJs.jsm
+++ b/browser/extensions/pdfjs/content/PdfJs.jsm
@@ -103,16 +103,18 @@ var PdfJs = {
     }
     PdfjsChromeUtils.init();
     this.initPrefs();
 
     Services.ppmm.sharedData.set("pdfjs.enabled", this.checkEnabled());
   },
 
   earlyInit() {
+    // Note: Please keep this in sync with the duplicated logic in
+    // nsBrowserGlue.js.
     Services.ppmm.sharedData.set("pdfjs.enabled", this.checkEnabled());
   },
 
   initPrefs: function initPrefs() {
     if (this._initialized) {
       return;
     }
     this._initialized = true;