Bug 1664701 - Delay loading Enigmail files in UI until they are needed. r=kaie
authorMark Banner <standard8@mozilla.com>
Sun, 01 Nov 2020 21:39:21 +0000
changeset 40378 1a685eb8be70782369e856e01e5496180ad73a69
parent 40377 f97d0a2f0cc65c58b844c85046f149d82197724f
child 40379 8fd1b44855a35346818ca6878759dfb3f1cccd05
push id2849
push userthunderbird@calypsoblue.org
push dateMon, 16 Nov 2020 19:06:44 +0000
treeherdercomm-beta@1cf7ad0dcfa6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaie
bugs1664701
Bug 1664701 - Delay loading Enigmail files in UI until they are needed. r=kaie Differential Revision: https://phabricator.services.mozilla.com/D90043
mail/base/content/hiddenWindowMac.xhtml
mail/base/test/performance/browser_startup.js
mail/extensions/openpgp/content/ui/enigmailMessengerOverlay.js
mail/extensions/openpgp/content/ui/enigmailMsgHdrViewOverlay.js
mailnews/extensions/smime/msgReadSMIMEOverlay.js
--- a/mail/base/content/hiddenWindowMac.xhtml
+++ b/mail/base/content/hiddenWindowMac.xhtml
@@ -29,17 +29,16 @@
 <script src="chrome://messenger/content/mail-offline.js"/>
 <script src="chrome://global/content/printUtils.js"/>
 <script src="chrome://messenger/content/msgViewPickerOverlay.js"/>
 <script src="chrome://messenger/content/viewZoomOverlay.js"/>
 <script src="chrome://communicator/content/utilityOverlay.js"/>
 <script src="chrome://messenger/content/mailCore.js"/>
 <script src="chrome://messenger/content/quickFilterBar.js"/>
 <script src="chrome://messenger/content/newmailaccount/uriListener.js"/>
-<script src="chrome://messenger-smime/content/msgReadSMIMEOverlay.js"/>
 <script src="chrome://messenger/content/customizable-toolbar.js"/>
 #ifdef XP_MACOSX
 <script src="chrome://global/content/macWindowMenu.js"/>
 #endif
 
 <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
 <stringbundle id="bundle_brand" src="chrome://branding/locale/brand.properties"/>
 <stringbundle id="bundle_search" src="chrome://messenger/locale/search.properties"/>
--- a/mail/base/test/performance/browser_startup.js
+++ b/mail/base/test/performance/browser_startup.js
@@ -41,33 +41,35 @@ const startupPhases = {
 
   // For the following phases of startup we have only a list of files that
   // are **not** allowed to load in this phase, as too many other scripts
   // load during this time.
 
   // We are at this phase after creating the first browser window (ie. after final-ui-startup).
   "before opening first browser window": {
     denylist: {
-      modules: new Set([]),
+      modules: new Set(["chrome://openpgp/content/modules/constants.jsm"]),
     },
   },
 
   // We reach this phase right after showing the first browser window.
   // This means that anything already loaded at this point has been loaded
   // before first paint and delayed it.
   "before first paint": {
     denylist: {
       modules: new Set([
         "resource://gre/modules/NewTabUtils.jsm",
+        "resource://gre/modules/Sqlite.jsm",
+        "chrome://openpgp/content/modules/core.jsm",
+        "chrome://openpgp/content/BondOpenPGP.jsm",
         // Bug 1660907: These core modules shouldn't really be being loaded
         // until sometime after first paint.
         // "resource://gre/modules/PlacesUtils.jsm",
         // "resource://gre/modules/Promise.jsm", // imported by devtools during _delayedStartup
         // "resource://gre/modules/Preferences.jsm",
-        // "resource://gre/modules/Sqlite.jsm",
         // These can probably be pushed back even further.
         "resource:///modules/MsgDBCacheManager.jsm",
         "resource:///modules/PeriodicFilterManager.jsm",
       ]),
       services: new Set(["@mozilla.org/browser/search-service;1"]),
     },
   },
 
--- a/mail/extensions/openpgp/content/ui/enigmailMessengerOverlay.js
+++ b/mail/extensions/openpgp/content/ui/enigmailMessengerOverlay.js
@@ -9,141 +9,72 @@
 // TODO: check if this is safe
 /* eslint-disable no-unsanitized/property */
 
 /* Globals from Thunderbird: */
 /* global ReloadMessage: false, gDBView: false, gSignatureStatus: false, gEncryptionStatus: false, showMessageReadSecurityInfo: false */
 /* global gFolderDisplay: false, messenger: false, currentAttachments: false, msgWindow: false, PanelUI: false */
 /* global currentHeaderData: false, gViewAllHeaders: false, gExpandedHeaderList: false, goDoCommand: false, HandleSelectedAttachments: false */
 /* global statusFeedback: false, displayAttachmentsForExpandedView: false, gMessageListeners: false, gExpandedHeaderView */
-/* globals gMessageNotificationBar, gMessageDisplay */
+/* globals gMessageNotificationBar, gMessageDisplay, Services */
 
 var { MailServices } = ChromeUtils.import(
   "resource:///modules/MailServices.jsm"
 );
-var { BondOpenPGP } = ChromeUtils.import(
-  "chrome://openpgp/content/BondOpenPGP.jsm"
-);
-
-var EnigmailCompat = ChromeUtils.import(
-  "chrome://openpgp/content/modules/compat.jsm"
-).EnigmailCompat;
-var EnigmailCore = ChromeUtils.import(
-  "chrome://openpgp/content/modules/core.jsm"
-).EnigmailCore;
-var EnigmailFuncs = ChromeUtils.import(
-  "chrome://openpgp/content/modules/funcs.jsm"
-).EnigmailFuncs;
-var EnigmailMsgRead = ChromeUtils.import(
-  "chrome://openpgp/content/modules/msgRead.jsm"
-).EnigmailMsgRead;
-var EnigmailVerify = ChromeUtils.import(
-  "chrome://openpgp/content/modules/mimeVerify.jsm"
-).EnigmailVerify;
-var EnigmailVerifyAttachment = ChromeUtils.import(
-  "chrome://openpgp/content/modules/verify.jsm"
-).EnigmailVerifyAttachment;
-var EnigmailFixExchangeMsg = ChromeUtils.import(
-  "chrome://openpgp/content/modules/fixExchangeMsg.jsm"
-).EnigmailFixExchangeMsg;
-var { EnigmailLog } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/log.jsm"
-);
-var EnigmailPrefs = ChromeUtils.import(
-  "chrome://openpgp/content/modules/prefs.jsm"
-).EnigmailPrefs;
-var { EnigmailOS } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/os.jsm"
-);
-var EnigmailLocale = ChromeUtils.import(
-  "chrome://openpgp/content/modules/locale.jsm"
-).EnigmailLocale;
-var EnigmailFiles = ChromeUtils.import(
-  "chrome://openpgp/content/modules/files.jsm"
-).EnigmailFiles;
-var { EnigmailKey } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/key.jsm"
-);
-var EnigmailData = ChromeUtils.import(
-  "chrome://openpgp/content/modules/data.jsm"
-).EnigmailData;
-var { EnigmailApp } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/app.jsm"
+var { XPCOMUtils } = ChromeUtils.import(
+  "resource://gre/modules/XPCOMUtils.jsm"
 );
-var EnigmailDialog = ChromeUtils.import(
-  "chrome://openpgp/content/modules/dialog.jsm"
-).EnigmailDialog;
-var EnigmailWindows = ChromeUtils.import(
-  "chrome://openpgp/content/modules/windows.jsm"
-).EnigmailWindows;
-var EnigmailTime = ChromeUtils.import(
-  "chrome://openpgp/content/modules/time.jsm"
-).EnigmailTime;
-var EnigmailPersistentCrypto = ChromeUtils.import(
-  "chrome://openpgp/content/modules/persistentCrypto.jsm"
-).EnigmailPersistentCrypto;
-var EnigmailStreams = ChromeUtils.import(
-  "chrome://openpgp/content/modules/streams.jsm"
-).EnigmailStreams;
-var EnigmailKeyRing = ChromeUtils.import(
-  "chrome://openpgp/content/modules/keyRing.jsm"
-).EnigmailKeyRing;
-var EnigmailKeyServer = ChromeUtils.import(
-  "chrome://openpgp/content/modules/keyserver.jsm"
-).EnigmailKeyServer;
-var { EnigmailKeyserverURIs } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/keyserverUris.jsm"
-);
-var EnigmailDecryption = ChromeUtils.import(
-  "chrome://openpgp/content/modules/decryption.jsm"
-).EnigmailDecryption;
-var EnigmailAttachment = ChromeUtils.import(
-  "chrome://openpgp/content/modules/attachment.jsm"
-).EnigmailAttachment;
-var EnigmailConstants = ChromeUtils.import(
-  "chrome://openpgp/content/modules/constants.jsm"
-).EnigmailConstants;
-var EnigmailURIs = ChromeUtils.import(
-  "chrome://openpgp/content/modules/uris.jsm"
-).EnigmailURIs;
-var EnigmailProtocolHandler = ChromeUtils.import(
-  "chrome://openpgp/content/modules/protocolHandler.jsm"
-).EnigmailProtocolHandler;
-var EnigmailAutocrypt = ChromeUtils.import(
-  "chrome://openpgp/content/modules/autocrypt.jsm"
-).EnigmailAutocrypt;
-var EnigmailMime = ChromeUtils.import(
-  "chrome://openpgp/content/modules/mime.jsm"
-).EnigmailMime;
-var EnigmailArmor = ChromeUtils.import(
-  "chrome://openpgp/content/modules/armor.jsm"
-).EnigmailArmor;
-/*
-var EnigmailWks = ChromeUtils.import(
-  "chrome://openpgp/content/modules/webKey.jsm"
-).EnigmailWks;
-*/
-var EnigmailStdlib = ChromeUtils.import(
-  "chrome://openpgp/content/modules/stdlib.jsm"
-).EnigmailStdlib;
-var EnigmailConfigure = ChromeUtils.import(
-  "chrome://openpgp/content/modules/configure.jsm"
-).EnigmailConfigure;
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var KeyLookupHelper = ChromeUtils.import(
-  "chrome://openpgp/content/modules/keyLookupHelper.jsm"
-).KeyLookupHelper;
-var { uidHelper } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/uidHelper.jsm"
-);
-var { PgpSqliteDb2 } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/sqliteDb.jsm"
-);
-
-var l10n = new Localization(["messenger/openpgp/openpgp.ftl"], true);
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+  BondOpenPGP: "chrome://openpgp/content/BondOpenPGP.jsm",
+  EnigmailArmor: "chrome://openpgp/content/modules/armor.jsm",
+  EnigmailAttachment: "chrome://openpgp/content/modules/attachment.jsm",
+  EnigmailApp: "chrome://openpgp/content/modules/app.jsm",
+  EnigmailAutocrypt: "chrome://openpgp/content/modules/autocrypt.jsm",
+  EnigmailCompat: "chrome://openpgp/content/modules/compat.jsm",
+  EnigmailConfigure: "chrome://openpgp/content/modules/configure.jsm",
+  EnigmailConstants: "chrome://openpgp/content/modules/constants.jsm",
+  EnigmailCore: "chrome://openpgp/content/modules/core.jsm",
+  EnigmailData: "chrome://openpgp/content/modules/data.jsm",
+  EnigmailDecryption: "chrome://openpgp/content/modules/decryption.jsm",
+  EnigmailDialog: "chrome://openpgp/content/modules/dialog.jsm",
+  EnigmailFixExchangeMsg: "chrome://openpgp/content/modules/fixExchangeMsg.jsm",
+  EnigmailFiles: "chrome://openpgp/content/modules/files.jsm",
+  EnigmailFuncs: "chrome://openpgp/content/modules/funcs.jsm",
+  EnigmailKey: "chrome://openpgp/content/modules/key.jsm",
+  EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.jsm",
+  EnigmailKeyServer: "chrome://openpgp/content/modules/keyserver.jsm",
+  EnigmailKeyserverURIs: "chrome://openpgp/content/modules/keyserverUris.jsm",
+  EnigmailLocale: "chrome://openpgp/content/modules/locale.jsm",
+  EnigmailLog: "chrome://openpgp/content/modules/log.jsm",
+  EnigmailMime: "chrome://openpgp/content/modules/mime.jsm",
+  EnigmailMsgRead: "chrome://openpgp/content/modules/msgRead.jsm",
+  EnigmailOS: "chrome://openpgp/content/modules/os.jsm",
+  EnigmailPersistentCrypto:
+    "chrome://openpgp/content/modules/persistentCrypto.jsm",
+  EnigmailPrefs: "chrome://openpgp/content/modules/prefs.jsm",
+  EnigmailProtocolHandler:
+    "chrome://openpgp/content/modules/protocolHandler.jsm",
+  EnigmailStdlib: "chrome://openpgp/content/modules/stdlib.jsm",
+  EnigmailStreams: "chrome://openpgp/content/modules/streams.jsm",
+  EnigmailTime: "chrome://openpgp/content/modules/time.jsm",
+  EnigmailURIs: "chrome://openpgp/content/modules/uris.jsm",
+
+  EnigmailVerify: "chrome://openpgp/content/modules/mimeVerify.jsm",
+  EnigmailVerifyAttachment: "chrome://openpgp/content/modules/verify.jsm",
+  EnigmailWindows: "chrome://openpgp/content/modules/windows.jsm",
+  // EnigmailWks: "chrome://openpgp/content/modules/webKey.jsm",
+  KeyLookupHelper: "chrome://openpgp/content/modules/keyLookupHelper.jsm",
+  PgpSqliteDb2: "chrome://openpgp/content/modules/sqliteDb.jsm",
+  uidHelper: "chrome://openpgp/content/modules/uidHelper.jsm",
+});
+
+XPCOMUtils.defineLazyGetter(this, "l10n", () => {
+  return new Localization(["messenger/openpgp/openpgp.ftl"], true);
+});
 
 var Enigmail;
 if (!Enigmail) {
   Enigmail = {};
 }
 
 Enigmail.getEnigmailSvc = function() {
   return EnigmailCore.getService(window);
--- a/mail/extensions/openpgp/content/ui/enigmailMsgHdrViewOverlay.js
+++ b/mail/extensions/openpgp/content/ui/enigmailMsgHdrViewOverlay.js
@@ -9,89 +9,45 @@
 /* Globals from Thunderbird: */
 /* global gFolderDisplay: false, currentAttachments: false, gCryptoContainer: false, gSignedUINode: false, gEncryptedUINode: false */
 /* global gDBView: false, msgWindow: false, messageHeaderSink: false, gMessageListeners: false, findEmailNodeFromPopupNode: true */
 /* global gExpandedHeaderView: false, CanDetachAttachments: true, gEncryptedURIService: false, FillAttachmentListPopup: false */
 /* global attachmentList: false, MailOfflineMgr: false, currentHeaderData: false, ContentTypeIsSMIME: false */
 
 /* import-globals-from ../BondOpenPGP.jsm */
 
-var EnigmailCore = ChromeUtils.import(
-  "chrome://openpgp/content/modules/core.jsm"
-).EnigmailCore;
-var EnigmailFuncs = ChromeUtils.import(
-  "chrome://openpgp/content/modules/funcs.jsm"
-).EnigmailFuncs;
-var EnigmailVerify = ChromeUtils.import(
-  "chrome://openpgp/content/modules/mimeVerify.jsm"
-).EnigmailVerify;
-var { EnigmailLog } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/log.jsm"
-);
-var EnigmailPrefs = ChromeUtils.import(
-  "chrome://openpgp/content/modules/prefs.jsm"
-).EnigmailPrefs;
-var EnigmailLocale = ChromeUtils.import(
-  "chrome://openpgp/content/modules/locale.jsm"
-).EnigmailLocale;
-var EnigmailWindows = ChromeUtils.import(
-  "chrome://openpgp/content/modules/windows.jsm"
-).EnigmailWindows;
-var EnigmailDialog = ChromeUtils.import(
-  "chrome://openpgp/content/modules/dialog.jsm"
-).EnigmailDialog;
-var EnigmailTime = ChromeUtils.import(
-  "chrome://openpgp/content/modules/time.jsm"
-).EnigmailTime;
-var { EnigmailGpg } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/gpg.jsm"
-);
-var { EnigmailKey } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/key.jsm"
+var { XPCOMUtils } = ChromeUtils.import(
+  "resource://gre/modules/XPCOMUtils.jsm"
 );
-var EnigmailKeyRing = ChromeUtils.import(
-  "chrome://openpgp/content/modules/keyRing.jsm"
-).EnigmailKeyRing;
-var EnigmailURIs = ChromeUtils.import(
-  "chrome://openpgp/content/modules/uris.jsm"
-).EnigmailURIs;
-var EnigmailConstants = ChromeUtils.import(
-  "chrome://openpgp/content/modules/constants.jsm"
-).EnigmailConstants;
-var EnigmailData = ChromeUtils.import(
-  "chrome://openpgp/content/modules/data.jsm"
-).EnigmailData;
-var EnigmailClipboard = ChromeUtils.import(
-  "chrome://openpgp/content/modules/clipboard.jsm"
-).EnigmailClipboard;
-var EnigmailStdlib = ChromeUtils.import(
-  "chrome://openpgp/content/modules/stdlib.jsm"
-).EnigmailStdlib;
-/*
-var EnigmailWks = ChromeUtils.import(
-  "chrome://openpgp/content/modules/webKey.jsm"
-).EnigmailWks;
-*/
-var EnigmailMime = ChromeUtils.import(
-  "chrome://openpgp/content/modules/mime.jsm"
-).EnigmailMime;
-var EnigmailMsgRead = ChromeUtils.import(
-  "chrome://openpgp/content/modules/msgRead.jsm"
-).EnigmailMsgRead;
-var EnigmailSingletons = ChromeUtils.import(
-  "chrome://openpgp/content/modules/singletons.jsm"
-).EnigmailSingletons;
-/*
-var EnigmailAutocrypt = ChromeUtils.import(
-  "chrome://openpgp/content/modules/autocrypt.jsm"
-).EnigmailAutocrypt;
-*/
-var EnigmailCompat = ChromeUtils.import(
-  "chrome://openpgp/content/modules/compat.jsm"
-).EnigmailCompat;
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+  // EnigmailAutocrypt: "chrome://openpgp/content/modules/autocrypt.jsm",
+  EnigmailClipboard: "chrome://openpgp/content/modules/clipboard.jsm",
+  EnigmailCompat: "chrome://openpgp/content/modules/compat.jsm",
+  EnigmailConstants: "chrome://openpgp/content/modules/constants.jsm",
+  EnigmailCore: "chrome://openpgp/content/modules/core.jsm",
+  EnigmailData: "chrome://openpgp/content/modules/data.jsm",
+  EnigmailDialog: "chrome://openpgp/content/modules/dialog.jsm",
+  EnigmailFuncs: "chrome://openpgp/content/modules/funcs.jsm",
+  EnigmailGpg: "chrome://openpgp/content/modules/gpg.jsm",
+  EnigmailKey: "chrome://openpgp/content/modules/key.jsm",
+  EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.jsm",
+  EnigmailLocale: "chrome://openpgp/content/modules/locale.jsm",
+  EnigmailLog: "chrome://openpgp/content/modules/log.jsm",
+  EnigmailMime: "chrome://openpgp/content/modules/mime.jsm",
+  EnigmailMsgRead: "chrome://openpgp/content/modules/msgRead.jsm",
+  EnigmailPrefs: "chrome://openpgp/content/modules/prefs.jsm",
+  EnigmailSingletons: "chrome://openpgp/content/modules/singletons.jsm",
+  EnigmailStdlib: "chrome://openpgp/content/modules/stdlib.jsm",
+  EnigmailTime: "chrome://openpgp/content/modules/time.jsm",
+  EnigmailURIs: "chrome://openpgp/content/modules/uris.jsm",
+  EnigmailVerify: "chrome://openpgp/content/modules/mimeVerify.jsm",
+  EnigmailWindows: "chrome://openpgp/content/modules/windows.jsm",
+  // EnigmailWks: "chrome://openpgp/content/modules/webKey.jsm",
+});
 
 if (!Enigmail) {
   var Enigmail = {};
 }
 
 Enigmail.hdrView = {
   lastEncryptedMsgKey: null,
   lastEncryptedUri: null,
--- a/mailnews/extensions/smime/msgReadSMIMEOverlay.js
+++ b/mailnews/extensions/smime/msgReadSMIMEOverlay.js
@@ -1,32 +1,31 @@
 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* globals gDBView, GetNumSelectedMessages */
-/* globals MailConstants, Enigmail, BondOpenPGP */
+/* globals MailConstants, Enigmail */
 /* global currentHeaderData: false */
 
+var { XPCOMUtils } = ChromeUtils.import(
+  "resource://gre/modules/XPCOMUtils.jsm"
+);
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+  BondOpenPGP: "chrome://openpgp/content/BondOpenPGP.jsm",
+  EnigmailConstants: "chrome://openpgp/content/modules/constants.jsm",
+  EnigmailFuncs: "chrome://openpgp/content/modules/funcs.jsm",
+  EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.jsm",
+  EnigmailWindows: "chrome://openpgp/content/modules/windows.jsm",
+});
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-var { EnigmailFuncs } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/funcs.jsm"
-);
-var { EnigmailConstants } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/constants.jsm"
-);
-var { EnigmailWindows } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/windows.jsm"
-);
-var { EnigmailKeyRing } = ChromeUtils.import(
-  "chrome://openpgp/content/modules/keyRing.jsm"
-);
-
 var gEncryptionStatus = -1;
 var gSignatureStatus = -1;
 var gSignerCert = null;
 var gEncryptionCert = null;
 var gSigKeyId = null;
 var gEncKeyId = null;
 
 var myl10n = new Localization(["messenger/openpgp/msgReadStatus.ftl"], true);