Closed Bug 2071182 Opened 2 months ago Closed 2 months ago

Network geolocation provider keeps sending requests after shutdown when a request was still in flight

Categories

(Toolkit :: Geolocation Provider, defect, P2)

Desktop
Unspecified
defect

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox-esr153 --- unaffected
firefox156 --- wontfix
firefox157 --- fixed
firefox158 --- fixed

People

(Reporter: jstutte, Assigned: jstutte)

References

(Blocks 2 open bugs, Regression)

Details

(Keywords: regression)

Attachments

(2 external files, 1 obsolete file)

Since bug 2048118 a NetworkGeolocationProvider that is shut down while a network request is in flight comes back to life when that request settles, and then runs its repeating timer for the rest of the browser session with no listener attached.

Mechanism (dom/system/NetworkGeolocationProvider.sys.mjs):

A failed request never populates gCachedRequest, so a resurrected provider issues one real GeoIP request per tick at the 20s backoff cap, 4320 per day, until the process exits. Every system-provider flap can leave one such instance behind: CoreLocation reporting kCLErrorLocationUnknown, starting the fallback and cancelling it again on the next position
(https://searchfox.org/firefox-main/rev/ffc07a625994a9db71c7b6fbfe4be2ed64ed1aee/dom/system/mac/CoreLocationLocationProvider.mm#320), or GeoClue erroring and recovering.

Before bug 2048118 part 1 the request completion paths did not touch the timer, so shutdown() was final. Firefox 154 and 155 carry the regression.

Telemetry (release 154, macOS, 2026-08-20 to 2026-09-10, 10% sample): one client issued 23 million network geolocation requests in three days, 12 million on the third day, all network_ip, all failed, zero geolocation_cache_hit, with about 1400 geolocation.fallback start/recover cycles per day and geolocation.macos_error_code[0] recorded 1785 times. About 1400 new instances per day accumulating over three days at 4320 requests each reproduces the observed rate. That single client accounts for nearly all of the 23.5 million requests recorded for release 154 on macOS in the four weeks to 2026-09-10, against 59 thousand that succeeded.

Proposed fix: make resetTimer() a no-op while this.started is false, and abort the in-flight fetch from shutdown() through the AbortController that fetchLocation already creates. A regression test can start the provider against an unreachable URL, call shutdown() while the request is pending, let it settle, and assert through nsITimerManager that no timer named after the provider remains.

:handyman, since you are the author of the regressor, bug 2048118, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(davidp99)

I am preparing a fix.

Flags: needinfo?(davidp99)

Set release status flags based on info from the regressing bug 2048118

The backoff handling added in bug 2048118 calls resetTimer() from the
request completion paths. Neither checks whether the provider is still
started, so a request that was in flight when shutdown() ran re-armed the
repeating timer and the provider kept issuing requests with no listener for
the rest of the session. Every system-provider fallback start/cancel cycle
could leave one such instance behind.

Make resetTimer() a no-op once the provider is shut down, and abort in-flight
requests from shutdown() so they settle right away. Add an xpcshell test that
shuts the provider down mid-request and checks that no provider timer
remains once the request completes.

Assignee: nobody → jstutte
Status: NEW → ASSIGNED
Severity: -- → S3
Priority: -- → P2
Blocks: 2072110
Pushed by jstutte@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/7a352ac1f472 https://hg.mozilla.org/integration/autoland/rev/c34eb80173d0 Keep NetworkGeolocationProvider shut down when a request settles after shutdown(). r=geoprovider-reviewers,saschanaz,handyman
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch

The patch landed in nightly and beta is affected.
:jstutte, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(jstutte)

The backoff handling added in bug 2048118 calls resetTimer() from the
request completion paths. Neither checks whether the provider is still
started, so a request that was in flight when shutdown() ran re-armed the
repeating timer and the provider kept issuing requests with no listener for
the rest of the session. Every system-provider fallback start/cancel cycle
could leave one such instance behind.

Make resetTimer() a no-op once the provider is shut down, and abort in-flight
requests from shutdown() so they settle right away. Add an xpcshell test that
shuts the provider down mid-request and checks that no provider timer
remains once the request completes.

Original Revision: https://phabricator.services.mozilla.com/D325308

Attachment #9643183 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: User impact is unclear (hangs or perf issues?) but it affects our GLS bill directly.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: None
  • Risk associated with taking this patch: low
  • Explanation of risk level: Just a more explicit shutdown handling.
  • String changes made/needed?: None
  • Is Android affected?: no
Flags: needinfo?(jstutte)
Attachment #9643183 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
See Also: → 2073443

The backoff handling added in bug 2048118 calls resetTimer() from the
request completion paths. Neither checks whether the provider is still
started, so a request that was in flight when shutdown() ran re-armed the
repeating timer and the provider kept issuing requests with no listener for
the rest of the session. Every system-provider fallback start/cancel cycle
could leave one such instance behind.

Make resetTimer() a no-op once the provider is shut down, and abort in-flight
requests from shutdown() so they settle right away. Add an xpcshell test that
shuts the provider down mid-request and checks that no provider timer
remains once the request completes.

Original Revision: https://phabricator.services.mozilla.com/D325308

Attachment #9678338 - Flags: approval-mozilla-esr115?
Attachment #9678338 - Flags: approval-mozilla-esr115? → approval-mozilla-esr115+
Attachment #9678338 - Attachment is obsolete: true
Attachment #9678338 - Flags: approval-mozilla-esr115+ → approval-mozilla-esr115-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: