Network geolocation provider keeps sending requests after shutdown when a request was still in flight
Categories
(Toolkit :: Geolocation Provider, defect, P2)
Tracking
()
| 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):
- The failure path of
sendLocationRequestcalls_increaseBackoff()and thenresetTimer().
https://searchfox.org/firefox-main/rev/ffc07a625994a9db71c7b6fbfe4be2ed64ed1aee/dom/system/NetworkGeolocationProvider.sys.mjs#436 - The success path calls
_resetBackoff()andresetTimer()whenever a backoff was in effect.
https://searchfox.org/firefox-main/rev/ffc07a625994a9db71c7b6fbfe4be2ed64ed1aee/dom/system/NetworkGeolocationProvider.sys.mjs#422 - Neither site checks
this.started, andresetTimer()unconditionally creates a newTYPE_REPEATING_SLACKtimer.
https://searchfox.org/firefox-main/rev/ffc07a625994a9db71c7b6fbfe4be2ed64ed1aee/dom/system/NetworkGeolocationProvider.sys.mjs#207 shutdown()cancels the timer and drops the listener, but does not abort the pendingfetch(). When that fetch settles afterwards, the provider re-arms itself.notify()then keeps callingsendLocationRequest(null); errors are dropped becauselisteneris null.
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.
Comment 1•2 months ago
|
||
: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.
Comment 3•2 months ago
|
||
Set release status flags based on info from the regressing bug 2048118
| Assignee | ||
Comment 4•2 months ago
|
||
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.
Updated•2 months ago
|
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Updated•2 months ago
|
Updated•2 months ago
|
Comment 6•2 months ago
|
||
| bugherder | ||
Comment 7•2 months ago
|
||
The patch landed in nightly and beta is affected.
:jstutte, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.
- If no, please set
status-firefox157towontfix.
For more information, please visit BugBot documentation.
| Assignee | ||
Comment 8•2 months ago
|
||
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
Updated•2 months ago
|
Comment 9•2 months ago
|
||
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
| Assignee | ||
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Comment 10•2 months ago
|
||
| uplift | ||
Updated•2 months ago
|
Comment 11•10 days ago
|
||
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
Updated•10 days ago
|
Updated•9 days ago
|
Updated•5 days ago
|
Description
•