Comments (3)
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.
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
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.
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)
- if http is not maintained, then what is the recommended plugin? HOT 2
- Allow fragments to be parsed as JSON in response data
- Could not cast value of type '__NSCFNumber' (0x10881b608) to 'NSString' (0x1f473fc40). HOT 1
- Allow WebDAV HTTP methods
- Sending request on background HOT 2
- Setup custom values in header not work.
- Request to https domain fails with SSLHandshakeException. HOT 5
- cannot overwrite default request headers on ios
- JSONException on device when getting a primitive value, e.g. number
- [feat] support metadata for uploadFile HOT 1
- downloadFile method not working correctly on Android
- Cannot get cookies in the response
- iOS and Android handle form-uurlencoded requests differently HOT 2
- How to write interceptor in capacitor http HOT 1
- https url is not hitting with http-community in IONIC React. HOT 1
- Capacitor v4 support? HOT 4
- setCookie: "errorMessage":"Must provide value"
- Capacitor 4 : Http urls not working (only https) HOT 2
- Unable to open asset URL on Android
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http.