Closed Bug 1687207 Opened 5 years ago Closed 5 years ago

MessageSend.jsm causes unnecessary loading of modules on startup

Categories

(MailNews Core :: Composition, defect)

defect

Tracking

(thunderbird_esr78 unaffected)

RESOLVED FIXED
86 Branch
Tracking Status
thunderbird_esr78 --- unaffected

People

(Reporter: standard8, Assigned: rnons)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(1 file)

MessageSend.jsm is loaded very early in startup, as it is not lazy loading its modules, it causes various other javascript modules to be loaded early than necessary.

On my machine with an SSD drive, it takes ~11ms to load all of these, on a HDD that is likely to be longer.

Things like:

var { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");

Should be using:

const { XPCOMUtils } = ChromeUtils.import(
  "resource://gre/modules/XPCOMUtils.jsm"
);

XPCOMUtils.defineLazyModuleGetters(this, {
  OS: "resource://gre/modules/osfile.jsm",
});

https://searchfox.org/comm-central/rev/e5bad7edc0e9cdb1e02f040ac5a2a60b984e9b6f/mailnews/addrbook/modules/AddrBookManager.jsm#7-18

or at worst, ChromeUtils.defineModuleGetter.

If things are needed straight away (e.g. XPCOMUtils in the example above), they can be directly imported, otherwise we should be lazy loading to help our startup times.

Attached patch 1687207.patchSplinter Review

Use defineLazyModuleGetters in MessageSend.jsm and SmtpService.jsm.

Assignee: nobody → remotenonsense
Status: NEW → ASSIGNED
Attachment #9197675 - Flags: review?(standard8)
Attachment #9197675 - Flags: review?(standard8) → review?(mkmelin+mozilla)
Comment on attachment 9197675 [details] [diff] [review] 1687207.patch Review of attachment 9197675 [details] [diff] [review]: ----------------------------------------------------------------- LGTM. Services is always going to be there so could potentially just be outside. But I don't think it matters much.
Attachment #9197675 - Flags: review?(mkmelin+mozilla) → review+
Target Milestone: --- → 86 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/cf4074b0e9f3
Use defineLazyModuleGetters in MessageSend.jsm and SmtpService.jsm. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: