Improve NetworkGeolocationProvider behavior and integration
Categories
(Toolkit :: Geolocation Provider, enhancement)
Tracking
()
People
(Reporter: handyman, Assigned: handyman)
References
Details
Attachments
(8 external files, 6 obsolete files)
The NetworkGeolocationProvider has some issues that cause it to run too frequently which, among other things, is not good for power usage. A list of things I'm looking at here includes:
- Coalesce concurrent requests and abort
fetchon shutdown. Moderate gain due to reducing waste (fewer network requests). - Persist the request cache beyond shutdown so new requests can hit it as soon as they start. High gain due to frequent cold starts (fewer network requests).
- Incrementally increase the retry timer duration while requests are failing. Reset to minimum on each
Startupcall (clients currently guard against calling twice but don't need to). Moderate improvement in power for clients issuing requests where geolocation is blocked or frequently fails. - Stop active MLS fallback when GeoClue recovers (a one-liner). Mild reduction in network usage.
| Assignee | ||
Comment 1•4 months ago
|
||
Add an in-flight guard so the repeating 5s timer and wifi onChange events no
longer stack overlapping network geolocation fetches while a request is slow
or the endpoint is failing. Callers are skipped in favor of reusing
(sufficiently precise) in-flight requests. Also store the AbortController on
the instance and abort any outstanding fetch in shutdown(), so the retry loop
does not outlive the provider.
| Assignee | ||
Comment 2•4 months ago
|
||
Stop clearing the cached response in shutdown(), so a recent position can be
reused across the provider's shutdown/restart cycles within a browser run,
avoiding a cold-start network request for each intermittent geolocation use.
Also observes network:link-status-changed and invalidates the cache on "changed"/"up". A
cached location is only valid on the network it came from (GeoIP depends on the
public IP, a wifi fix on the visible access points). The observer lives on the
cache, so invalidation also works while the provider is shut down.
| Assignee | ||
Comment 3•4 months ago
|
||
Apply bounded exponential backoff to the repeating request timer after network
failures (increasing up to geo.provider.network.backoffMaxMs, default 20s) so a
failing or unreachable endpoint is not retried every 5s indefinitely, which
drains battery on always-on machines. The backoff is reset to the normal
cadence on a new watch request and on a successful response, so genuine
requests are never delayed by a prior failure's backoff.
| Assignee | ||
Comment 4•4 months ago
|
||
UpdateLastPosition only stopped the fallback wait timer, so an MLS fallback
that had already started (e.g. after a GeoClue error) kept running its
NetworkGeolocation provider -- issuing network requests for the rest of the
session -- despite GeoClue producing positions again. Shut down an active
fallback on recovery with "ProviderResponded", matching how CoreLocation and
Portal work.
| Assignee | ||
Comment 5•4 months ago
|
||
Reset the NetworkGeolocationProvider failure backoff whenever a different
provider falls back, which can happen multiple times.
Comment 6•4 months ago
|
||
Do we have a design doc somewhere where we can talk?
| Assignee | ||
Updated•4 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
| Assignee | ||
Comment 7•3 months ago
|
||
Stop clearing gCachedRequest in shutdown() so a recent position can be reused
across the provider's stop/restart cycles within a browser run, instead of
cold-starting a network request for each intermittent geolocation use.
https://hg.mozilla.org/mozilla-central/rev/96b176e7f711
https://hg.mozilla.org/mozilla-central/rev/68c8dbccfb16
https://hg.mozilla.org/mozilla-central/rev/c6adf7f59917
https://hg.mozilla.org/mozilla-central/rev/1d4b090b0792
| Assignee | ||
Comment 10•3 months ago
|
||
Apply bounded exponential backoff to the repeating request timer after network
failures (increasing up to geo.provider.network.backoffMaxMs, default 20s) so a
failing or unreachable endpoint is not retried every 5s indefinitely, which
drains battery on always-on machines. The backoff is reset to the normal
cadence on a new watch request and on a successful response, so genuine
requests are never delayed by a prior failure's backoff.
Original Revision: https://phabricator.services.mozilla.com/D309730
Updated•3 months ago
|
| Assignee | ||
Comment 11•3 months ago
|
||
UpdateLastPosition only stopped the fallback wait timer, so an MLS fallback
that had already started (e.g. after a GeoClue error) kept running its
NetworkGeolocation provider -- issuing network requests for the rest of the
session -- despite GeoClue producing positions again. Shut down an active
fallback on recovery with "ProviderResponded", matching how CoreLocation and
Portal work.
Original Revision: https://phabricator.services.mozilla.com/D309731
Updated•3 months ago
|
| Assignee | ||
Comment 12•3 months ago
|
||
Reset the NetworkGeolocationProvider failure backoff whenever a different
provider falls back, which can happen multiple times.
Original Revision: https://phabricator.services.mozilla.com/D309732
Updated•3 months ago
|
Comment 13•3 months ago
|
||
firefox-beta Uplift Approval Request
- User impact if declined/Reason for urgency: Excessive, wasteful, battery draining and costly use of Google Location Services, especially on Linux.
- Code covered by automated testing?: yes
- Fix verified in Nightly?: no
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: The patches affect how the network geolocation cache (primarily used on Linux) is dirtied. The highest risk is believed to be geolocation using slightly stale information, which is minor and not likely to be exposed in nightly.
- String changes made/needed?: None
- Is Android affected?: no
| Assignee | ||
Comment 14•3 months ago
|
||
Stop clearing gCachedRequest in shutdown() so a recent position can be reused
across the provider's stop/restart cycles within a browser run, instead of
cold-starting a network request for each intermittent geolocation use.
Original Revision: https://phabricator.services.mozilla.com/D313338
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Comment 15•3 months ago
|
||
| uplift | ||
| Assignee | ||
Comment 16•7 days ago
|
||
Apply bounded exponential backoff to the repeating request timer after network
failures (increasing up to geo.provider.network.backoffMaxMs, default 20s) so a
failing or unreachable endpoint is not retried every 5s indefinitely, which
drains battery on always-on machines. The backoff is reset to the normal
cadence on a new watch request and on a successful response, so genuine
requests are never delayed by a prior failure's backoff.
Original Revision: https://phabricator.services.mozilla.com/D309730
Updated•7 days ago
|
| Assignee | ||
Comment 17•7 days ago
|
||
UpdateLastPosition only stopped the fallback wait timer, so an MLS fallback
that had already started (e.g. after a GeoClue error) kept running its
NetworkGeolocation provider -- issuing network requests for the rest of the
session -- despite GeoClue producing positions again. Shut down an active
fallback on recovery with "ProviderResponded", matching how CoreLocation and
Portal work.
Original Revision: https://phabricator.services.mozilla.com/D309731
Updated•7 days ago
|
| Assignee | ||
Comment 18•7 days ago
|
||
Reset the NetworkGeolocationProvider failure backoff whenever a different
provider falls back, which can happen multiple times.
Original Revision: https://phabricator.services.mozilla.com/D309732
Updated•7 days ago
|
| Assignee | ||
Comment 19•7 days ago
|
||
Stop clearing gCachedRequest in shutdown() so a recent position can be reused
across the provider's stop/restart cycles within a browser run, instead of
cold-starting a network request for each intermittent geolocation use.
Original Revision: https://phabricator.services.mozilla.com/D313338
Updated•7 days ago
|
Updated•7 days ago
|
Updated•7 days ago
|
Updated•7 days ago
|
Updated•7 days ago
|
Updated•3 days ago
|
Updated•3 days ago
|
Updated•3 days ago
|
Updated•3 days ago
|
Description
•