Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress is unreliable #88

Open
matt-curtis opened this issue Jun 27, 2017 · 4 comments
Open

Progress is unreliable #88

matt-curtis opened this issue Jun 27, 2017 · 4 comments

Comments

@matt-curtis
Copy link

Testing all with Google Drive:

  • GTMSessionFetcher.downloadedLength is 0 until the download finishes, instead of updating as more bytes are received
  • When using GTMSessionFetcher's downloadProgressBlock totalBytesExpectedToWrite is always 0 or -1.
  • GTMSessionFetcher's beginFetchWithCompletionHandler is returning nil NSData, even though it successfully saves the file to disk. Intentional?

Tested on iPhone 6, iOS 9.3.

@mwyman
Copy link
Contributor

mwyman commented Jun 27, 2017

It sounds like you're setting the destinationFileURL.

In that case, we're not updating downloadedLength like we do with data tasks (no destination file URL), however you can provide a download progress block and receive the current status as it updates.

For totalBytesExpectedToWrite, all network clients are at the mercy of the server sending the Content-Length header, which I believe Google Drive does not send when responding to an HTTP GET request. To show a useful progress indicator, in the past I've needed to get the file size from elsewhere (e.g. making a HEAD request before starting the fetch).

With destinationFileURL set, the completion handler's NSData will be intentionally nil. All data is written directly to the file as it's received and not retained in memory. This is useful for large files, files not intended to be used immediately, etc. So the fetcher does not re-load the bytes into memory on completion, avoiding file I/O and memory allocation that are potentially unneeded.

@matt-curtis
Copy link
Author

matt-curtis commented Jun 27, 2017

That's pretty much what I guessed, though I don't understand why setting downloadedLength should differ between data and destination tasks, it's useful in both cases?

@mwyman
Copy link
Contributor

mwyman commented Jun 29, 2017

downloadedLength not being updated is likely just an oversight. No clear reason to me why it's not being updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@mwyman @matt-curtis and others
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy