-
Notifications
You must be signed in to change notification settings - Fork 887
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
Timeouts after downloading a lot of files (iOS) #260
Comments
@elvisgraho We removed the cached response to improve the memory usage when transferring a lot of files. CDVFileTransferDelegate* currentDelegate = command.activeTransfers[objectId];
[[NSURLCache sharedURLCache] removeCachedResponseForRequest:currentDelegate.connection.currentRequest]; |
@elvisgraho are you doing multiple downloads at the same time? @sdkester did you add that code after each transfer? I'm trying to workaround timeouts here too and I keep seeing errors about "Background task X, was created over 30 seconds ago..." so I think iOS is killing the tasks which then results in a file transfer timeoutt |
@nunohorta No. One download after another. "*Note that my JS code explicitly waits for [self.command.commandDelegate sendPluginResult:result callbackId:callbackId]; before sending next request." "Background task X, was created over 30 seconds ago" issue is fixable when you set the request timeout in Objective-C code. The funny thing is, that the default timeout is 60 secs, but the max timeout for Background tasks is 30. After that I'v got further Problems that are deeply rooted in iOS and deprecated HTTP client functions that are used in this plugin. The issue is that "[connection cancel];" does not actually cancel the connection. It is an asynchronous process that tells the low-level code to perform a cleanup. Once the cache gets full, it gets stuck. What fixed the issue for me is:
|
@nunohorta Like @elvisgraho I control the number of file transfers that are sent to the cordova plugin. My preferred library is the queue flow control in AsyncJS. This lets us send one or two file download requests at a time with a realtime queue waiting for additions and completions. |
Bug Report
Problem
When you download a lot (more than 200) of files (images) consecutively, NSMutableURLRequest gets stuck after 50+ successful requests (and a few requests after that), because of the connection timeout.
You can see when it starts to happen, because few connections will get slower and slower until eventually it will time out.
Possibly this link is related, idk.
As mentioned in the link above, [connection cancel] does nothing.
What is expected to happen?
No timeouts.
What does actually happen?
Timeouts.
Rewriting success call did not help but seem to improve a performance a little bit.
*Note that my JS code explicitly waits for
[self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
before sending next request.The text was updated successfully, but these errors were encountered: