Closed Bug 2073443 Opened 2 months ago Closed 1 month ago

Network geolocation requests that get an unparseable 200 response are counted as successful, never cached, and retried at the backoff cap

Categories

(Toolkit :: Geolocation Provider, defect)

defect

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: jstutte, Assigned: jstutte)

References

(Blocks 2 open bugs)

Details

Attachments

(1 external file, 1 obsolete file)

NetworkGeolocationProvider.fetchLocation increments geolocation.geolocation_service[network_ip|network_wifi_and_ip] right before the POST and increments geolocation.network_failures only when fetch() throws or the response status is not 2xx. It then returns response.json() unawaited. When the body is not the expected JSON, the parse rejects inside the try block of sendLocationRequest (as does the result.location.lng access when location is missing). That catch path notifies the listener and grows the backoff, but it neither records a failure nor fills gCachedRequest, so the next repeating-timer tick sends another real request. With a watchPosition consumer this loops at the backoff cap (geo.provider.network.backoffMaxMs, 20 s), up to 4,320 requests per day.

Two populations hit this on release:

  1. Windows 152+ ships neither the GLS key nor a geo.provider.network.url default (bug 2037099). When the network provider is still selected there (geo.provider.ms-windows-location=false, geo.provider.use_mls, or geo.provider.testing, see bug 2048776), formatURLPref returns about:blank, the POST gets an empty 200 and the loop starts. In release telemetry for 154/155 these client-days show hundreds to thousands of "successful" requests per day with zero cache hits and zero failures; Google never sees them.
  2. Clients behind a proxy, antivirus web shield or captive portal that answers 200 with an HTML page, on any platform.

Both inflate the successful-request series used as the billable proxy (dashboard 3070 on STMO) and keep the provider hammering an endpoint that cannot answer.

Suggested fix:

  • Count JSON parse and shape failures under network_failures (same label, or a dedicated bad_response label) so they stop reading as successes.
  • Do not issue a request at all when the formatted URL is about:blank or empty; report POSITION_UNAVAILABLE instead. That alone ends the Windows loop.
  • xpcshell test: serve a 200 with an HTML body, assert the failure counter increments, the cache stays empty and no request storm follows (same HttpServer setup as dom/geolocation/test/unit/test_geolocation_provider_shutdown.js).

Code: https://searchfox.org/firefox-main/rev/572cbc53633d3ed8a0b1390828611752f0317938/dom/system/NetworkGeolocationProvider.sys.mjs (fetchLocation and the catch in sendLocationRequest).

A 2xx response whose body is not JSON, or is JSON without a location, was
counted as a successful request and never as a failure. Count it under
geolocation.network_failures like a non-2xx status.

When geo.provider.network.url has no value, formatURLPref() returns
about:blank and the provider POSTed to it on every timer tick. Fail the
request without sending anything instead.

Assignee: nobody → jstutte
Attachment #9644669 - Attachment description: WIP: Bug 2073443 - Treat unparseable network geolocation responses as failures and skip requests without a service URL. r?#geoprovider-reviewers → Bug 2073443 - Treat unparseable network geolocation responses as failures and skip requests without a service URL. r?#geoprovider-reviewers
Status: NEW → ASSIGNED
Blocks: 2074762
Pushed by jstutte@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b698bcb40846 https://hg.mozilla.org/integration/autoland/rev/85b7ba6e9ca1 Treat unparseable network geolocation responses as failures and skip requests without a service URL. r=geoprovider-reviewers,handyman
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
QA Whiteboard: [qa-triage-done-c159/b158]

A 2xx response whose body is not JSON, or is JSON without a location, was
counted as a successful request and never as a failure. Count it under
geolocation.network_failures like a non-2xx status.

When geo.provider.network.url has no value, formatURLPref() returns
about:blank and the provider POSTed to it on every timer tick. Fail the
request without sending anything instead.

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

Attachment #9678340 - Flags: approval-mozilla-esr115?
Attachment #9678340 - Flags: approval-mozilla-esr115? → approval-mozilla-esr115+
Attachment #9678340 - Attachment is obsolete: true
Attachment #9678340 - 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: