You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/06/25 08:56:10 UTC

[GitHub] [cordova-plugin-file-transfer] elvisgraho opened a new issue #260: Timeouts after downloading a lot of files (iOS)

elvisgraho opened a new issue #260:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/260


   # Bug Report
   
   ## Problem
   When you download a lot (more than 200) of files (images) consecutively, NSMutableURLRequest gets stuck for a while (and a few requests after that), because of the connection timeout.
   
   Possibly this [link](https://stackoverflow.com/questions/13369386/how-to-cancel-a-persistent-connection-using-nsurlconnection) 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.
   
   ``` ojbective-c
       // remove connection for activeTransfers
       @synchronized (command.activeTransfers) {
           [connection cancel];
           [command.activeTransfers removeObjectForKey:objectId];
           // remove background id task in case our upload was done in the background
           [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskID];
           self.backgroundTaskID = UIBackgroundTaskInvalid;
           
           [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
       }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-plugin-file-transfer] nunohorta commented on issue #260: Timeouts after downloading a lot of files (iOS)

Posted by GitBox <gi...@apache.org>.
nunohorta commented on issue #260:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/260#issuecomment-673401428


   @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


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-plugin-file-transfer] elvisgraho edited a comment on issue #260: Timeouts after downloading a lot of files (iOS)

Posted by GitBox <gi...@apache.org>.
elvisgraho edited a comment on issue #260:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/260#issuecomment-676018520


   @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: 
   1. Ditch this plugin
   2. Use HTTP from @ionic-native/http (You can download files with it.)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-plugin-file-transfer] elvisgraho edited a comment on issue #260: Timeouts after downloading a lot of files (iOS)

Posted by GitBox <gi...@apache.org>.
elvisgraho edited a comment on issue #260:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/260#issuecomment-676018520


   @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 thins 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: 
   1. Ditch this plugin
   2. Use HTTP from @ionic-native/http (You can download files with it.)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-plugin-file-transfer] sdkester commented on issue #260: Timeouts after downloading a lot of files (iOS)

Posted by GitBox <gi...@apache.org>.
sdkester commented on issue #260:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/260#issuecomment-676504820


   @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](https://caolan.github.io/async/v3/docs.html#queue). This lets us send one or two file download requests at a time with a realtime queue waiting for additions and completions. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-plugin-file-transfer] elvisgraho edited a comment on issue #260: Timeouts after downloading a lot of files (iOS)

Posted by GitBox <gi...@apache.org>.
elvisgraho edited a comment on issue #260:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/260#issuecomment-676018520


   @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 issue is that 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: 
   1. Ditch this plugin
   2. Use HTTP from @ionic-native/http (You can download files with it.)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-plugin-file-transfer] elvisgraho edited a comment on issue #260: Timeouts after downloading a lot of files (iOS)

Posted by GitBox <gi...@apache.org>.
elvisgraho edited a comment on issue #260:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/260#issuecomment-676018520


   @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 remove the concurrency in the Objective-C request code. 
   
   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: 
   1. Ditch this plugin
   2. Use HTTP from @ionic-native/http (You can download files with it.)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[GitHub] [cordova-plugin-file-transfer] sdkester commented on issue #260: Timeouts after downloading a lot of files (iOS)

Posted by GitBox <gi...@apache.org>.
sdkester commented on issue #260:
URL: https://github.com/apache/cordova-plugin-file-transfer/issues/260#issuecomment-657851500


   @elvisgraho We removed the cached response to improve the memory usage when transferring a lot of files.
   
   ```objc
   CDVFileTransferDelegate* currentDelegate = command.activeTransfers[objectId];
   [[NSURLCache sharedURLCache] removeCachedResponseForRequest:currentDelegate.connection.currentRequest];
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org