Skip to content

docs: note Linux performance characteristics of getApplicationNameForProtocol - #51099

Closed
officialasishkumar wants to merge 1 commit into
electron:mainfrom
officialasishkumar:docs/app-get-application-name-for-protocol-perf
Closed

officialasishkumar wants to merge 1 commit into
electron:mainfrom
officialasishkumar:docs/app-get-application-name-for-protocol-perf

Conversation

@officialasishkumar

Copy link
Copy Markdown
Contributor

Description of Change

The Linux implementation of Browser::GetApplicationNameForProtocol() invokes xdg-mime query default via base::GetAppOutputWithExitCode, which spawns a subprocess and blocks on its exit. macOS (via LSCopyDefaultApplicationURLForURL in browser_mac.mm) and Windows (via AssocQueryString in browser_win.cc) both resolve the default handler in-process through system APIs, so the Linux path is orders of magnitude slower.

This performance gap is easy to miss when development and testing happen primarily on macOS or Windows, and it can bite apps that call the API on a hot path (for example, when determining the handler for every outbound link).

This PR adds a note to the API documentation describing the difference and recommending that callers on hot paths cache the result, so app developers can avoid repeated slow invocations on Linux without needing to read the platform-specific implementations.

Refs #49727

Checklist

Release Notes

Notes: none

@electron-cation electron-cation Bot added documentation 📓 semver/patch backwards-compatible bug fixes new-pr 🌱 PR opened recently labels Apr 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR contains unsigned commits. This repository enforces commit signatures
for all incoming PRs. To get your PR merged, please sign those commits
(git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch
(git push --force-with-lease)

For more information on signing commits, see GitHub's documentation on Telling Git about your signing key.

@github-actions github-actions Bot added the needs-signed-commits Currently some or all of the commits in this PR are not signed label Apr 16, 2026
@officialasishkumar
officialasishkumar force-pushed the docs/app-get-application-name-for-protocol-perf branch from 4ed3b0f to 27272fc Compare April 16, 2026 18:17
@github-actions github-actions Bot removed the needs-signed-commits Currently some or all of the commits in this PR are not signed label Apr 16, 2026
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Apr 17, 2026

@ckerr ckerr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs to be rebased on main to fix this linting issue:

2026-04-16T18:38:00.3987755Z Checking formatting...
2026-04-16T18:38:00.3988044Z 
2026-04-16T18:38:00.5144584Z spec/fixtures/crash-cases/webview-destroy-in-event/index.js (0ms)
2026-04-16T18:38:00.5145150Z 
2026-04-16T18:38:00.5145562Z Format issues found in above 1 files. Run without `--check` to fix.

@ckerr

ckerr commented Apr 21, 2026

Copy link
Copy Markdown
Member

Hmm I wonder if we could just make this faster by using g_app_info_get_default_for_uri_scheme() + g_app_info_get_display_name() 🤔

I'll poke around on this and see.

…Protocol

The Linux implementation of Browser::GetApplicationNameForProtocol()
invokes `xdg-mime query default` via base::GetAppOutputWithExitCode,
which spawns a subprocess and blocks on its exit. macOS (via
LSCopyDefaultApplicationURLForURL) and Windows (via AssocQueryString)
both resolve the default handler in-process through system APIs, so the
Linux path is orders of magnitude slower and is easy to overlook when
a build profile runs on those platforms.

Add a note to the API documentation describing this difference and
recommending that callers on hot paths cache the result, so developers
can avoid repeated slow invocations on Linux without needing to read
the browser_linux.cc implementation.

Refs: electron#49727
Signed-off-by: Asish Kumar <[email protected]>
@officialasishkumar
officialasishkumar force-pushed the docs/app-get-application-name-for-protocol-perf branch from 27272fc to 72940d3 Compare April 22, 2026 08:21
@officialasishkumar

Copy link
Copy Markdown
Contributor Author

Rebased onto main and re-signed the commit.

@ckerr

ckerr commented Apr 23, 2026

Copy link
Copy Markdown
Member

Superseded by #51251 -- we no longer spawn a process for this 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📓 semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants