Closed Bug 1347146 Opened 7 years ago Closed 3 months ago

devtools network monitor counts service worker cached responses against "transferred"

Categories

(DevTools :: Netmonitor, defect, P3)

defect

Tracking

(firefox122 fixed)

RESOLVED FIXED
122 Branch
Tracking Status
firefox122 --- fixed

People

(Reporter: bkelly, Assigned: bomsy)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files)

Its great that devtools network monitor now shows a separate "transferred" size, but I don't think its quite handling service workers correctly.  In general we should not count responses returned from a service worker as transferred.

If the service worker actually got the response from the network it will show up as its own line in the netmonitor with cause "fetch".  That line should count towards the transfer total, but not then counted again when returned from the service worker.

For example, see the attached screenshot.  Here most of the resources are offline cached by the service worker and should not be counted at all.  The "/" resource does do a network revalidation, but otherwise the site does not use the network at all.  Devtools shows that 480kb were transferred, when it should be close to zero.
Looks like the devtools change landed in FF54, so we should try to fix it there.
Priority: -- → P3
Product: Firefox → DevTools
Severity: normal → S3

Interesting to note that if the service worker redirects to another file, the transferred size will be 0, as expected.

eg page requests "foo.css", serviceworker fetches "bar.css" and returns the response for "bar.css", transferred size will show 0.
It seems that when the cache is hit for a different URL than the one requested initially, the onProgress (nsIProgressEventSink) callback for our NetworkResponseListener is never triggered.

Regardless of this, we have a clear flag for requests which were transferred to a serviceworker (httpActivity.fromServiceWorker) so we should be able to handle this in DevTools and set a transferred size of 0.

Alternatively if we could APIs on the channel or the request to get the size information (header size, transferred size etc...), I feel like this could be more reliable than our current implementation?

Attachment #9363988 - Attachment description: WIP: Bug 1347146 - [devtools] Test that the total transferred size does not include service worker requests → WIP: Bug 1347146 - [devtools] Make sure that the total transferred size does not include service worker requests #devtools-reviewers
Assignee: nobody → hmanilla
Attachment #9363988 - Attachment description: WIP: Bug 1347146 - [devtools] Make sure that the total transferred size does not include service worker requests #devtools-reviewers → Bug 1347146 - [devtools] Make sure that the total transferred size does not include service worker requests r=#devtools-reviewers
Status: NEW → ASSIGNED
Pushed by hmanilla@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9ea04a2cc829
[devtools] Make sure that the total transferred size does not include service worker requests r=devtools-reviewers,nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 122 Branch
You need to log in before you can comment on or make changes to this bug.