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

Only one download success when add urls in for loop #21

Closed
igiu1988 opened this issue Mar 11, 2014 · 10 comments
Closed

Only one download success when add urls in for loop #21

igiu1988 opened this issue Mar 11, 2014 · 10 comments
Labels

Comments

@igiu1988
Copy link

I have many files to downloa. Many of them are mp3 file with size 200KB500KB,and several video with size 10MB40MB. So I code like this :

for (......)
{
[[TCBlobDownloadManager sharedInstance] startDownloadWithURL:url customPath:downloadPath delegate:self];
}

But I find only one or two log printed out from download:didReceiveFirstResponse delegate. All other files all not download. Finaly, a friend told me to comment the code

//        self.speedTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
//                                                           target:self
//                                                         selector:@selector(updateTransferRate)
//                                                         userInfo:nil
//                                                          repeats:YES];
//        [runLoop addTimer:self.speedTimer forMode:NSRunLoopCommonModes];

in method - (void)start in file TCBlobDownload, then download queue will be normal. I try and it indeed works. But I don't and stand why, so my friend too. May you explain this ?

@thibaultcha
Copy link
Owner

Thanks for the report. I am investigating on this. I see no reason but I'll tell you if I find anything.

@igiu1988
Copy link
Author

Later on that day, a friend told me comment the timer code in method
"start" in TCBlobDownloader.m, then the Download queue will process
normaly. But, both I and my friend dont understand why. Later, I will post
the code to you.
ÔÚ 2014-3-17 AM2:09£¬"Thibault" notifications@github.comдµÀ£º

Thanks for the report. I am investigating on this. I see no reason but
I'll tell you if I find anything.

¡ª
Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-37764870
.

@thibaultcha
Copy link
Owner

Yeah I understood that.

@bradleydwyer
Copy link

I'm seeing this as well. It's not consistently the first download, but that's the highest probability.

I've been adding 5 items in a loop, and anywhere from 1 to all 5 of the items will be downloaded. Commenting out the speed timer appears to avoid the issue. In most cases, only one operation is invoked however.

At the time of the issue, I had the operation queue set to 1 concurrent operation. The start method is not invoked on subsequent operations.

Adding small delays to the invocation of the block syntax variant of

startDownloadWithURL

didn't change the behaviour (where the small delay was invoking it asynchronously on the main thread via GCD - in 5 separate blocks, or via a custom serial dispatch queue).

I haven't had a chance to dig into the code to see why removing the timer works, I'm on a bit of a deadline at the moment and I don't need the speed details right now.

@thibaultcha
Copy link
Owner

Thank you, it helps. I've been digging two weeks ago but I'm not done, and I don't have time those days. This is bothering me, I will take a look at it again.

@thibaultcha
Copy link
Owner

I just pushed a fix (3674251) after investigating this afternoon, seeing your issue, seeing that the concurrent downloads were broken etc... I tested it (the NSRunLoop timer thing is still there) and I can now download 50 video files concurrently without issues. I also tested it with 1000 downloads of the master.zip archive of this GitHub repository, one by one, no troubles. (each one in a separated file though, as the library requires)

Can you test it?

@bradleydwyer
Copy link

Sure. I'll have a chance to test it tomorrow (in about 28 hours from now).

@bradleydwyer
Copy link

So far so good. I've downloaded a couple of dozen items with 3 concurrent and it's been working without a problem.

@thibaultcha
Copy link
Owner

Alright, perfect then! I updated TCBlobDownload to 1.5.1 in cb6587a. Let me know in case anything goes wrong!

Thanks

@bradleydwyer
Copy link

Will do. I'll switch across to using that version in a few minutes. It'll be getting a bit of testing from the team over the next day or so. Will let you know if anything pops up.

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

No branches or pull requests

3 participants