Skip to content

perf(desktop): install the context menu after the first window exists - #49794

Closed
Hona wants to merge 1 commit into
v2from
lazy-context-menu
Closed

Hona wants to merge 1 commit into
v2from
lazy-context-menu

Conversation

@Hona

@Hona Hona commented Sep 18, 2026

Copy link
Copy Markdown
Member

\configureApplication\ imported \�lectron-context-menu\ at module level and called it before \�pp.whenReady(). In the Chromium startup trace its dependency chain (\�lectron-dl, \cli-truncate, \�xt-name, \�moji-regex, …) is the block of
equire()\ events right before our own chunks evaluate.

\�lectron-context-menu\ attaches to every window that already exists (\BrowserWindow.getAllWindows()) and to future ones (\�rowser-window-created), so it does not need to be configured before windows are created. This moves it to \installContextMenu, run in
unIpc\ right after
estoreWindows(); the options are unchanged.

Measured with \�un run bench:startup\ (#49758): packaged \�2\ build, isolated home, warm service, median of 6 launches.

baseline this PR
first main-process log line (\�pp starting) 401 ms 381 ms
shell visible 1,325 ms 1,278 ms

Same family as #49791 / #49792: third-party CommonJS on the pre-ready path.

electron-context-menu (with electron-dl, cli-truncate, ext-name and
friends) was imported and configured in configureApplication, before
Chromium was ready. It attaches to every existing and future window, so
loading it right after restoreWindows() gives the same menus without
its dependency tree on the startup path.

Packaged build, warm service, median of 6 launches: first main-process
log line 401 -> 381 ms after spawn.
@Hona
Hona requested a review from Brendonovich as a code owner September 18, 2026 14:35
Copilot AI lite review requested due to automatic review settings September 18, 2026 14:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Hona added a commit that referenced this pull request Sep 19, 2026
The context menu call lived in configureApplication and was lost when
that moved to the entry module. Install it after restoreWindows(), where
electron-context-menu attaches to existing and future windows alike,
which also keeps its dependency tree off the startup path (#49794).
@Hona

Hona commented Sep 19, 2026

Copy link
Copy Markdown
Member Author

Folded into #49869: the early-window entry moves configureApplication, and the context menu now installs after restoreWindows() there.

@Hona Hona closed this Sep 19, 2026
Hona added a commit that referenced this pull request Sep 19, 2026
The context menu call lived in configureApplication and was lost when
that moved to the entry module. Install it after restoreWindows(), where
electron-context-menu attaches to existing and future windows alike,
which also keeps its dependency tree off the startup path (#49794).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants