New issue
Advanced search Search tips

Issue 711717 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 453357
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Failure to Download a File after Pausing

Reported by masonlev...@gmail.com, Apr 14 2017

Issue description

Device name: Pixel

From "Settings > About Chrome"
Application version: 57.0.2987.132
Operating system: Android 7.1.2; Pixel Build/N2G47E

URLs (if applicable): http://www.thinkbroadband.com/download.html

Steps to reproduce:
(1) Go to specified URL
(2) Long press red "1GB (v. large)" box
(3) Press "Download link" in the context menu that was brought up from the long press
(4) Press menu and then Downloads
(5) Pause the download
(6) Wait for at least 30 seconds
(7) Resume the download

Expected result:
Download would resume and successfully download the entire 1GB zip


Actual result:
The download seems to resume, but then completes obviously too quick and the final file size is much less than 1GB



 
Screenshot_20170414-104313.png
54.2 KB View Download
Cc: krav...@chromium.org
Components: UI>Browser>Downloads
Labels: triage-te
Labels: Needs-Feedback
We are not able to access this url - http://www.thinkbroadband.com/download.html


Can you provide the URLs of some sites on which you experience this issue? other than this url -http://www.thinkbroadband.com/download.html? This will help us reproduce what you are seeing.

I believe the download failure will happen with any download. Just find a file large enough so you have time to pause the download before it completes. 
Project Member

Comment 4 by sheriffbot@chromium.org, Apr 15 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "kravula@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: -krav...@chromium.org qin...@chromium.org
Labels: -triage-te ReleaseBlock-Stable M-59 Type-Bug
Owner: dtrainor@chromium.org
Status: Assigned (was: Unconfirmed)
I am able to repro with large files.

Comment 6 by qin...@chromium.org, Apr 17 2017

this also reproduces on  linux desktop

Comment 7 by qin...@chromium.org, Apr 17 2017

Cc: -qin...@chromium.org dtrainor@chromium.org xingliu@chromium.org
Owner: qin...@chromium.org
I think waiting for 30 seconds probably closes the connection. And that causes reading from the socket to end prematurely.

The url request log indicates that the download failed with ERR_CONTENT_LENGTH_MISMATCH, somehow we still rename the file and treat it as if it completes. 

Will look into this.

Comment 8 by qin...@chromium.org, Apr 17 2017

ok, in HttpStreamParser::DoReadBodyComplete(), we have this comment:

  //  - If a Content-Length header is present and the body contains fewer bytes
  //    than promised by the header at connection close, it may indicate that
  //    the connection was closed prematurely, or it may indicate that the
  //    server sent an invalid Content-Length header. Unfortunately, the invalid
  //    Content-Length header case does occur in practice and other browsers are
  //    tolerant of it. We choose to treat it as an error for now, but the
  //    download system treats it as a non-error, and URLRequestHttpJob also
  //    treats it as OK if the Content-Length is the post-decoded body content
  //    length.

Comment 9 by qin...@chromium.org, Apr 17 2017

This is curretly expected as pause() always leave the connection open. If server closes the connection before resume() is called, then we end up with this situation. 

Chrome cannot differentiate whether the connection was closed or whether the content-length header is incorrect.

One possible solution is to always cancel the request when pause() is called, and then resend a new request on resumption. That will create a new connection, but it will also introduce re-download issues if content-length is not present.
correct myself: the last sentence should be "re-download issues if strong validators are not present"
Cc: asanka@chromium.org
Asanka@, any thoughts on this?

pausing a download for more than 30 seconds seems common. But if the connection is closed, then the download will end in a wrong size.
This is the same as  issue 453357 .

The underlying cause and possible remediations are discussed briefly there.
Interesting, we have some code to handle ERR_CONTENT_LENGTH_MISMATCH in download_request_core, does it make sense to add more logic to let the download system know, that we're in this situation and we may create a new connection when Resume() is called after a Pause().

But if there is no strong validators, I guess we shouldn't resume with a new connection.

Also, even if the download system knows it, we still have the edge case(very rare) that the connection is actually being closed and the user pause, at this point it's hard to tell if a new connection is needed.

+asanka into cc list. 
I think we can send a new range request if we found that the downloaded content size mismatches with the content-length, before completing the download
Cc: shaktisahu@chromium.org
I'd suggest duping this into  issue 453357  and continuing there. The suggested approach is to treat ERR_CONTENT_LENGTH_MISMATCH as an error, map it to a corresponding interrupt reason, and allow that interrupt to resume automatically.

We'd end up with an interrupted download if the there were no strong validators. In that case, users may lose data they would've previously been able to access. This is a case which we'll need to look into further. One option is to condition the behavior based on whether the response is byte addressible, and only consider it an error in that case.

Either way there's no need to keep two bugs open for this.
Mergedinto: 453357
Status: Duplicate (was: Assigned)

Sign in to add a comment