fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
913 stars 514 forks source link

[IOS] Fatal Exception: NSRangeException taskDictFromRecordArray #218

Closed catacs closed 2 years ago

catacs commented 4 years ago

I am getting this crash into production:

Fatal Exception: NSRangeException
*** -[__NSArrayM objectAtIndex:]: index 9223372036854775807 beyond bounds [0 .. 11]
-[FlutterDownloaderPlugin taskDictFromRecordArray:]
Fatal Exception: NSRangeException
0  CoreFoundation                 0x1bd4e7180 __exceptionPreprocess
1  libobjc.A.dylib                0x1bc6bf9f8 objc_exception_throw
2  CoreFoundation                 0x1bd460bec _CFArgv
3  CoreFoundation                 0x1bd3d2644 _CFDataInit
4  Runner                         0x10074a234 -[FlutterDownloaderPlugin taskDictFromRecordArray:] + 472 (FlutterDownloaderPlugin.m:472)
5  Runner                         0x10074a0d0 -[FlutterDownloaderPlugin loadTaskWithId:] + 460 (FlutterDownloaderPlugin.m:460)
6  Runner                         0x10074dc60 -[FlutterDownloaderPlugin URLSession:task:didCompleteWithError:] + 864 (FlutterDownloaderPlugin.m:864)
7  CFNetwork                      0x1bdc6b420 __51-[NSURLSession delegate_task:didCompleteWithError:]_block_invoke.182
8  Foundation                     0x1bdf4ccf4 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
9  Foundation                     0x1bde58d90 -[NSBlockOperation main]
10 Foundation                     0x1bde58278 -[__NSOperationInternal _start:]
11 Foundation                     0x1bdf4ea78 __NSOQSchedule_f
12 libdispatch.dylib              0x1bcf24a38 _dispatch_call_block_and_release
13 libdispatch.dylib              0x1bcf257d4 _dispatch_client_callout
14 libdispatch.dylib              0x1bceca01c _dispatch_continuation_pop$VARIANT$mp
15 libdispatch.dylib              0x1bcec96e0 _dispatch_async_redirect_invoke
16 libdispatch.dylib              0x1bced6030 _dispatch_root_queue_drain
17 libdispatch.dylib              0x1bced68d4 _dispatch_worker_thread2
18 libsystem_pthread.dylib        0x1bd1061b4 _pthread_wqthread
19 libsystem_pthread.dylib        0x1bd108cd4 start_wqthread
om-ha commented 4 years ago

I am getting this exact crash.

It always happens when there are ongoing downloads (enqueued & running) then the user triggers adding new downloads.

Stack Trace

Thread _CFDataInit

Fatal Exception: NSRangeException
*** -[__NSArrayM objectAtIndex:]: index 9223372036854775807 beyond bounds [0 .. 11]

Fatal Exception: NSRangeException
0  CoreFoundation                 0x19d03d5f0 __exceptionPreprocess
1  libobjc.A.dylib                0x19cd5fbcc objc_exception_throw
2  CoreFoundation                 0x19d0930cc -[__NSCFString characterAtIndex:].cold.1
3  CoreFoundation                 0x19cf16b98 _CFDataInit
4  flutter_downloader             0x10068e3f4 (Missing)
5  flutter_downloader             0x10068e074 (Missing)
6  flutter_downloader             0x100691c1c (Missing)
7  CFNetwork                      0x1a0430548 _CFNetworkHTTPConnectionCacheSetLimit
8  Foundation                     0x19d403fa0 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
9  Foundation                     0x19d30f2c0 -[NSBlockOperation main]
10 Foundation                     0x19d4061fc __NSOPERATION_IS_INVOKING_MAIN__
11 Foundation                     0x19d30efc4 -[NSOperation start]
12 Foundation                     0x19d406bf4 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__
13 Foundation                     0x19d4066c0 __NSOQSchedule_f
14 libdispatch.dylib              0x19ccb5c8c _dispatch_block_async_invoke2
15 libdispatch.dylib              0x19cd03524 _dispatch_client_callout
16 libdispatch.dylib              0x19ccabe98 _dispatch_continuation_pop$VARIANT$mp
17 libdispatch.dylib              0x19ccab5ec _dispatch_async_redirect_invoke
18 libdispatch.dylib              0x19ccb8438 _dispatch_root_queue_drain
19 libdispatch.dylib              0x19ccb8bf8 _dispatch_worker_thread2
20 libsystem_pthread.dylib        0x19cd54b38 _pthread_wqthread
21 libsystem_pthread.dylib        0x19cd57740 start_wqthread

Thread CLSProcessRecordAllThreads

Crashed: com.twitter.crashlytics.ios.exception
SIGABRT ABORT 0x000000019ce32d88

Crashed: com.twitter.crashlytics.ios.exception
0  Runner                         0x1001d7a74 CLSProcessRecordAllThreads + 4370709108
1  Runner                         0x1001d7e5c CLSProcessRecordAllThreads + 4370710108
2  Runner                         0x1001c76c8 CLSHandler + 4370642632
3  Runner                         0x1001d606c __CLSExceptionRecord_block_invoke + 4370702444
4  libdispatch.dylib              0x19cd03524 _dispatch_client_callout + 16
5  libdispatch.dylib              0x19ccb60b0 _dispatch_lane_barrier_sync_invoke_and_complete + 56
6  Runner                         0x1001d5ad8 CLSExceptionRecord + 4370701016
7  Runner                         0x1001d5904 CLSExceptionRecordNSException + 4370700548
8  Runner                         0x1001d54f8 CLSTerminateHandler() + 4370699512
9  libc++abi.dylib                0x19ce0614c std::__terminate(void (*)()) + 16
10 libc++abi.dylib                0x19ce060e4 std::terminate() + 44
11 libobjc.A.dylib                0x19cd5fe04 _objc_terminate() + 10
12 libdispatch.dylib              0x19cd03538 _dispatch_client_callout + 36
13 libdispatch.dylib              0x19ccabe98 _dispatch_continuation_pop$VARIANT$mp + 412
14 libdispatch.dylib              0x19ccab5ec _dispatch_async_redirect_invoke + 656
15 libdispatch.dylib              0x19ccb8438 _dispatch_root_queue_drain + 376
16 libdispatch.dylib              0x19ccb8bf8 _dispatch_worker_thread2 + 124
17 libsystem_pthread.dylib        0x19cd54b38 _pthread_wqthread + 212
18 libsystem_pthread.dylib        0x19cd57740 start_wqthread + 8

Devices

om-ha commented 4 years ago

Could be a race condition.

Here are some related issues on Stackoverflow:

suhail-zartek commented 4 years ago

@om-ha any solutions?

suhail-zartek commented 4 years ago

I'm getting the same error

suhail-zartek commented 4 years ago

@catacs Did you solve this?

catacs commented 4 years ago

@suhail-zartek I am not working on the project using this plug-in anymore. I guess the problem was not solved. Hope you find a solution soon.

chuber50 commented 3 years ago

Still getting this at 1.6.0 - any solutions yet?

PrzeszafBrightHR commented 2 years ago

Any update on that?

bartekpacia commented 2 years ago

This was fixed.