Closed Bug 1374686 Opened 4 years ago Closed 4 years ago

Lazily load LoginManagerContextMenu and SpellCheckHelper in nsContextMenu.js

Categories

(Firefox :: General, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 56
Tracking Status
firefox56 --- fixed

People

(Reporter: MattN, Assigned: MattN)

References

(Blocks 1 open bug, )

Details

Attachments

(2 files)

browser_startup.js made it obvious that we're importing LoginManagerContextMenu.jsm before the first context menu opening which isn't necesssary.
I didn't add a test for SpellCheckHelper since I don't know enough about it to know when it should load from other callers but it didn't hurt to make it lazy here anyways. It did remove it from browser_startup on my local machine though.
Component: Password Manager → General
Product: Toolkit → Firefox
Summary: Lazily load LoginManagerContextMenu.jsm → Lazily load LoginManagerContextMenu and SpellCheckHelper in nsContextMenu.js
Comment on attachment 8879607 [details]
Bug 1374686 - Don't import LoginManagerContextMenu.jsm during startup.

https://reviewboard.mozilla.org/r/150942/#review155744

::: browser/base/content/nsContextMenu.js:16
(Diff revision 1)
>  Components.utils.import("resource://gre/modules/Services.jsm");
>  
>  
>  XPCOMUtils.defineLazyModuleGetter(this, "LoginHelper",
>    "resource://gre/modules/LoginHelper.jsm");
> +XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerContextMenu",

It seems that making this a lazy getter will load it only when needed while showing the context menu (there's a check at http://searchfox.org/mozilla-central/rev/2bcd258281da848311769281daf735601685de2d/browser/base/content/nsContextMenu.js#605 ), but will load it unconditionally when hiding the context menu (at http://searchfox.org/mozilla-central/rev/2bcd258281da848311769281daf735601685de2d/browser/base/content/nsContextMenu.js#149 ).

Should we add a check in the hiding method? Could be done using Cu.isModuleLoaded.

::: browser/base/content/test/performance/browser_startup.js:77
(Diff revision 1)
>        "resource:///modules/AboutNewTab.jsm",
>        "resource:///modules/DirectoryLinksProvider.jsm",
>        "resource://gre/modules/BookmarkHTMLUtils.jsm",
>        "resource://gre/modules/Bookmarks.jsm",
>        "resource://gre/modules/ContextualIdentityService.jsm",
> +      "resource://gre/modules/LoginManagerContextMenu.jsm",

If the patch is making this completely disappear from the test's output, you want to blacklist the module for the "before handling user events" phase.
Comment on attachment 8879608 [details]
Bug 1374686 - Lazily import SpellCheckHelper in nsContextMenu.js.

https://reviewboard.mozilla.org/r/150944/#review155752

Looks good, thanks!

I have a vague plan to load nsContextMenu.js lazily in the future, but I haven't experimented with that yet, so I'm not sure it'll actually happen.
Attachment #8879608 - Flags: review?(florian) → review+
Comment on attachment 8879607 [details]
Bug 1374686 - Don't import LoginManagerContextMenu.jsm during startup.

https://reviewboard.mozilla.org/r/150942/#review155916
Attachment #8879607 - Flags: review?(florian) → review+
Pushed by mozilla@noorenberghe.ca:
https://hg.mozilla.org/integration/autoland/rev/838dc4a2ed61
Don't import LoginManagerContextMenu.jsm during startup. r=florian
https://hg.mozilla.org/integration/autoland/rev/798a5d133c0b
Lazily import SpellCheckHelper in nsContextMenu.js. r=florian
https://hg.mozilla.org/mozilla-central/rev/838dc4a2ed61
https://hg.mozilla.org/mozilla-central/rev/798a5d133c0b
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 56
You need to log in before you can comment on or make changes to this bug.