Giter Site home page Giter Site logo

Comments (3)

jkbz64 avatar jkbz64 commented on June 26, 2024 1

To dampen the issue I would advise you @fireonmac to make sure you are removing the listeners after you have created them and don't need anymore and/or early exit for the specific files - or simply just do not subscribe multiple times, it will double the number of callbacks.

If you happen to use react or other library/framework which re-render children on component state change (where you might store the number of downloaded bytes), make sure the stored progress change doesn't actually do that!

from http.

jkbz64 avatar jkbz64 commented on June 26, 2024

Note: I'm not a maintainer but I did write the initial progress implementation.

iOS implementation uses .default NSURLSession which under the hood most likely uses variable "buffer" size depending on your device/network connection, whenever URLSessionDownloadDelegate calls back the
urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) it returns bytesWritten incremented by the "buffer" length (assuming the buffer gets filled every time) and also might potentially postpone the call to the method so it may feel "better".

Currently the android implementation uses fixed buffer of 1024 bytes which will make roughly 100k calls for 100MB file to the progress listener - again, assuming the buffer gets filled everytime

@thomasvidas

Is there any specific reason buffer size of 1024 bytes was chosen? I think typical size for the network packet will be power of two in the range of 512b -> 32kb.
Raising the buffer size to let's say 8192 bytes would reduce number of listener calls by almost ten times on fast connections (where the problem is very apparent) and probably would alleviate the problem without having to go into much more complicated solutions for reasonable sized files. If you have nothing against I can open the PR, doesn't seem like a big deal considering progress isn't usually used for very small files.

from http.

nurfgun avatar nurfgun commented on June 26, 2024

am on the same team with @fireonmac. and i can confirm that we make sure that only one listener is attached at all time and the component containing percentage get refreshed only once in a while with a throttle. Not so much difference it makes thou.
We are currently using a fork of this repo with #195 as a temporary workaround and hope this resolves soon!
Thanks for your great work, @jkbz64 btw.

from http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.