Android Components: HttpIconLoader partially loads Icons if content length is not specified
Categories
(Fenix :: General, defect)
Tracking
(firefox128 wontfix, firefox129 wontfix, firefox130 wontfix, firefox131 wontfix, firefox132 wontfix, firefox133 fixed)
People
(Reporter: artemchep, Assigned: calu)
References
(Regression)
Details
(Keywords: regression, Whiteboard: [fxdroid] [group4])
Attachments
(1 file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0
Steps to reproduce:
This bug is related to org.mozilla.components:browser-icons:127.0.2
.
Extend mozilla.components.browser.icons.BrowserIcons
with a custom preparer that points to icons that do not have the Content-Length
header in the response. This makes mozilla.components.browser.icons.loader.HttpIconLoader#toIconLoaderResult(...)
go the alternative route that sometimes loads icons only partially.
Actual results:
while (inputStream.read(buffer).also { bytesInChunk = it } != -1) {
outStream.write(buffer, 0, bytesInChunk)
bytesRead += bytesInChunk
if (bytesRead > MAX_DOWNLOAD_BYTES || bytesRead > memoryInfoProvider.getAvailMem()) {
return@useStream IconLoader.Result.NoResult
}
if (bytesInChunk < DEFAULT_BUFFER_SIZE) {
break
}
}
This snippet assumes that InputStream#read(...)
always reads the size of the buffer bytes, unless it's the end of a content. Unfortunately that is not correct, InputStream#read(...)
can return any value in range of -1..buffer.size, where only -1 means the end of a content.
This results in an icon sometimes partially loading if the server returns less bytes then requested in a single read.
Expected results:
while (inputStream.read(buffer).also { bytesInChunk = it } != -1) {
outStream.write(buffer, 0, bytesInChunk)
bytesRead += bytesInChunk
if (bytesRead > MAX_DOWNLOAD_BYTES || bytesRead > memoryInfoProvider.getAvailMem()) {
return@useStream IconLoader.Result.NoResult
}
}
Additional condition check should be removed.
Comment 1•5 months ago
|
||
The severity field is not set for this bug.
:royang, could you have a look please?
For more information, please visit BugBot documentation.
Updated•5 months ago
|
Comment 2•5 months ago
|
||
Hi Cathy, can you please take a look? The reporter thinks that we don't need the check:
if (bytesInChunk < DEFAULT_BUFFER_SIZE) {
break
}
Updated•5 months ago
|
Updated•5 months ago
|
Updated•5 months ago
|
Comment 3•5 months ago
|
||
The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.
Updated•4 months ago
|
Assignee | ||
Comment 4•4 months ago
|
||
Hey Donal, we use HttpIconLoader for all sorts of images from websites.
I tried just removing the check but the tests fail, I'll try and take a look at the tests soon.
Comment 5•4 months ago
|
||
Set release status flags based on info from the regressing bug 1847372
Updated•3 months ago
|
Updated•3 months ago
|
Updated•2 months ago
|
Comment 6•2 months ago
|
||
Hi calu, just resurfacing this based on comment 4 to make sure this didn't fall off your radar.
Assignee | ||
Comment 7•2 months ago
|
||
Assignee | ||
Updated•2 months ago
|
Assignee | ||
Updated•2 months ago
|
Updated•2 months ago
|
Comment 9•2 months ago
|
||
bugherder |
Comment 10•2 months ago
|
||
Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.
Comment 11•2 months ago
|
||
The patch landed in nightly and beta is affected.
:calu, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- If no, please set
status-firefox132
towontfix
.
For more information, please visit BugBot documentation.
Assignee | ||
Updated•2 months ago
|
Description
•