mzeeshanid / MZDownloadManager

This download manager uses NSURLSession api to download files. It can download multiple files at a time. It can download large files if app is in background. It can resume downloads if app was quit.
BSD 3-Clause "New" or "Revised" License
1.12k stars 238 forks source link

Crash MZDownloadManager.swift line 180 #48

Open appcelerate opened 7 years ago

appcelerate commented 7 years ago

looks like this happends when the user press the home button and opens the app after a few minutes again.

specialized MZDownloadManager.(URLSession(URLSession, downloadTask : URLSessionDownloadTask, didWriteData : Int64, t

Crashed: com.apple.main-thread 0 MZDownloadManager 0x1010e8538 specialized MZDownloadManager.(URLSession(URLSession, downloadTask : URLSessionDownloadTask, didWriteData : Int64, totalBytesWritten : Int64, totalBytesExpectedToWrite : Int64) -> ()).(closure #1) (MZDownloadManager.swift:180) 1 MZDownloadManager 0x1010ec1fc partial apply for MZDownloadManager.(URLSession(URLSession, downloadTask : URLSessionDownloadTask, didWriteData : Int64, totalBytesWritten : Int64, totalBytesExpectedToWrite : Int64) -> ()).(closure #1) (MZDownloadManager.swift) 2 libdispatch.dylib 0x1804fe9e0 _dispatch_call_block_and_release + 24 3 libdispatch.dylib 0x1804fe9a0 _dispatch_client_callout + 16 4 libdispatch.dylib 0x1805035e8 _dispatch_main_queue_callback_4CF + 996 5 CoreFoundation 0x1815f50c8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 6 CoreFoundation 0x1815f2ce4 __CFRunLoopRun + 1572 7 CoreFoundation 0x181522da4 CFRunLoopRunSpecific + 424 8 GraphicsServices 0x182f8c074 GSEventRunModal + 100 9 UIKit 0x1877dd058 UIApplicationMain + 208

vishnuag05 commented 7 years ago

@appcelerate I am also facing same issue , I believe its because you have started so many downloads and during this function some downloads may be finished . I tried this dint get the error after - if self.downloadingArray.count > index { self.downloadingArray[index] = downloadModel } else { for (index, downloadModel) in self.downloadingArray.enumerated() { if downloadTask.isEqual(downloadModel.task) { self.downloadingArray[index] = downloadModel } } }

Let me know if its @mzeeshanid appropriate to use. @mzeeshanid I believe you havent used synchronization for delegate functions

appcelerate commented 7 years ago

@vishnuag05 thanks for reply,

but i configured it that you can only download one file. If its completed u can download an other one.

And what do u mean with

I believe you havent used synchronization for delegate functions

Regards Dennis

YogeshBhattGWL commented 1 year ago

Any solution guys? I am facing retain count error here

tejua commented 11 months ago

@appcelerate @vishnuag05 getting same issue after changes Any other solution ?