Open Bug 1973003 Opened 20 hours ago Updated 19 hours ago

Request size is wrong when request is served from cache

Categories

(DevTools :: Netmonitor, defect)

defect

Tracking

(Not tracked)

People

(Reporter: ochameau, Unassigned)

References

Details

STR:

It is wrongly reported to be 70,42 Ko, whereas, if you force reload via Ctrl+R, you get the expected size of 1,92 Ko.

Also, in the details panel, we see a transfered size of 0 bytes (Other cached files seem to be fine).
And as a result, the menu entry "save the response" doesn't work either, I get an empty file.

This type of cached image request was handled via bug 1722759, but this was modified more recently via bug 1916960.

For some reason channel.contentLength is reporting a size of 70048 from this code:
https://searchfox.org/mozilla-central/rev/beba5cde846f944c4d709e75cbe499d17af880a4/devtools/server/actors/resources/network-events-content.js#232-240

networkEventActor.addResponseContent(
  {
    mimeType: channel.contentType,
    size: channel.contentLength,
    text: "",
    transferredSize: 0,
  },
  {}
);

channel's transferSize, decodedBodySize, encodedBodySize are all set to 0.

I imagine that it is set to a wrong value over there:
https://searchfox.org/mozilla-central/rev/beba5cde846f944c4d709e75cbe499d17af880a4/image/imgLoader.cpp#1936-1941

RefPtr<mozilla::image::Image> image = request->GetImage();
if (image) {
  newChannel->SetContentLength(aEntry->GetDataSize());
}
obsService->NotifyObservers(newChannel, "http-on-resource-cache-response",
                            nullptr);

I imagine the Image's data size isn't the svg text size...

Depends on: 1722759

Which may ultimately come from this other size-setting logic:
https://searchfox.org/mozilla-central/rev/beba5cde846f944c4d709e75cbe499d17af880a4/image/imgRequest.cpp#575-578

RefPtr<Image> image = GetImage();
SizeOfState state(moz_malloc_size_of);
size_t size = image->SizeOfSourceWithComputedFallback(state);
mCacheEntry->SetDataSize(size);

I imagine this is mapped to this method.

It sounds like a bad idea to try to query the image size, especially for SVG as we may have extra non-visible text (xml comments).
May be we could use imgCacheEntry::GetDataSize?

You need to log in before you can comment on or make changes to this bug.