Request size is wrong when request is served from cache
Categories
(DevTools :: Netmonitor, defect)
Tracking
(Not tracked)
People
(Reporter: ochameau, Unassigned)
References
Details
STR:
- open https://mozfr.pascalc.net/
- look at request's size for
bars.svg
file
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.
Comment 1•20 hours ago
•
|
||
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.
Reporter | ||
Comment 2•19 hours ago
|
||
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,
},
{}
);
Reporter | ||
Comment 3•19 hours ago
|
||
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...
Reporter | ||
Comment 4•19 hours ago
|
||
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?
Description
•