Open Bug 2074009 Opened 12 days ago Updated 1 day ago

Add isDefaultBrowserAsync() to nsIShellService and migrate callers

Categories

(Firefox :: Shell Integration, task)

task

Tracking

()

ASSIGNED

People

(Reporter: janv, Assigned: janv)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: leave-open)

Attachments

(13 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

nsIShellService::isDefaultBrowser() is currently synchronous. On Linux, checking the default browser may involve D-Bus, so calling it synchronously on the main thread can block Firefox.

As a first step towards making the Linux implementation truly asynchronous, add an isDefaultBrowserAsync() API to nsIShellService and migrate as many consumers as practical to use it.

Initially, the async implementation can simply call the existing synchronous implementation and resolve the returned value immediately. This keeps the behavior unchanged while allowing callers to be converted to an async API.

In a follow-up, the Linux implementation can move the potentially blocking work off the main thread so that D-Bus access no longer blocks Firefox UI.

This bug should also update affected tests and mocks to support the new async API.

This blocks the broader bug 2044186 for making D-Bus-related internal APIs asynchronous.

Clean up nsGNOMEShellService::IsDefaultBrowser() in preparation for adding the
asynchronous implementation.

Add an asynchronous variant of isDefaultBrowser() to nsIShellService and expose
it through ShellService as well.

For now, the platform implementations call the existing synchronous logic and
resolve the result immediately. This allows callers to migrate to the async API
before the Linux implementation is moved off the main thread.

Use the asynchronous default-browser check when generating the Heartbeat
post-answer URL.

Use the asynchronous default-browser check when collecting the Telemetry
environment settings.

Propagate the asynchronous operation through the settings update path.

Use the asynchronous default-browser check when retrieving the default-browser
state in ClientEnvironmentBase.

Propagate the asynchronous operation to UsageReporting and its test.

Keywords: leave-open

Make nsToolkitShellService provide the shared nsISupports implementation,
including reference counting and QueryInterface for nsIToolkitShellService.

Update the platform shell services to fully inherit that implementation and
document the IsDefaultBrowser() virtual hook in preparation for adding a shared
nsIShellService::isDefaultBrowserAsync() implementation.

Attachment #9647993 - Attachment description: Bug 2074009 - Streamline nsToolkitShellService as a shared base class; r=#firefox-desktop-core-reviewers,#gtk-reviewers → Bug 2074009 - Rename nsToolkitShellService to nsShellService and streamline the shared base class; r=#firefox-desktop-core-reviewers,#gtk-reviewers
Pushed by jvarga@igalia.com: https://github.com/mozilla-firefox/firefox/commit/d62eed02d8e0 https://hg.mozilla.org/integration/autoland/rev/736b684d3fd9 Rename nsToolkitShellService to nsShellService and streamline the shared base class; r=gtk-reviewers,emilio https://github.com/mozilla-firefox/firefox/commit/caf56d40d2a4 https://hg.mozilla.org/integration/autoland/rev/d0df11fe3948 Add isDefaultBrowserAsync() to nsIShellService; r=gtk-reviewers,emilio

Return early from _updateDefaultBrowser() before session restore, following
the pattern used by _updateSearchEngine(). Log ignored calls instead of
assigning null to isDefaultBrowser.

The metric is recorded before session restore, when the default-browser value
is not yet available, and is not updated when the delayed check completes.

Move the Glean write into _updateDefaultBrowser() so it records the check’s
result after session restore. Add a test assertion that the metric contains a
boolean.

The delayed default-browser test waits for search service initialization but
not for the default-browser check. It currently passes with the trivial async
implementation, but could become flaky when the check runs on a background
thread and takes longer.

Add a small async work tracker so the test can await both operations before
checking the telemetry environment. The helper can also support other async
work started by EnvironmentCache observers.

Pushed by jvarga@igalia.com: https://github.com/mozilla-firefox/firefox/commit/2f6dea86ff7b https://hg.mozilla.org/integration/autoland/rev/9a9ba6e7119f Ignore early default-browser updates in TelemetryEnvironment; r=TravisLong https://github.com/mozilla-firefox/firefox/commit/687d92e91cf5 https://hg.mozilla.org/integration/autoland/rev/95365cb6f4cc Record browser.default_at_launch after the delayed default-browser check; r=TravisLong

Use the asynchronous default-browser check when recording the result of the
set-to-default Spotlight.

Use the asynchronous default-browser check when determining whether the
default-browser prompt should be shown.

Use the asynchronous default-browser check when determining whether About
Welcome needs to set Firefox as the default browser.

Update the related About Welcome targeting tests to stub the asynchronous API.

Use the asynchronous default-browser check for the cached and uncached ASRouter
targeting attributes. Together with the preceding migrations, this removes
default-browser checks as a source of UI stalls during startup.

Update the related ASRouter tests to use and stub the asynchronous API.

Depends on: 2077441
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: