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 513 forks source link

Example app crashes on iOS under the latest stable Flutter #623

Closed JannieT closed 1 year ago

JannieT commented 2 years ago

On iOS the example app crashes when terminating the app while a download is in progress:

Steps to reproduce:

  1. run the example app from this repo
  2. trigger a long download by tapping on the download icon next to one of the videos
  3. while the download is in progress, swipe the app out of memory

Expected behaviour

The service can handle a sudden termination gracefully

Actual behavior

The app crashed with the following report:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: 49CB1284-ED6B-4844-9614-5ABE2C7A6092
CrashReporter Key:   FBB2FEBD-5ECC-741F-4CCE-96FED13EC12E
Hardware Model:      MacBookPro15,2
Process:             Runner [28708]
Path:                /Users/USER/Library/Developer/CoreSimulator/Devices/8658AF85-42A9-4F6B-8308-1696026B7848/data/Containers/Bundle/Application/70E10683-5E04-4F24-BB74-BF03612E2527/Runner.app/Runner
Identifier:          vn.hunghd.downloader.example
Version:             1.0.0 (1)
Code Type:           X86-64 (Native)
Role:                Foreground
Parent Process:      launchd_sim [27237]
Coalition:           com.apple.CoreSimulator.SimDevice.8658AF85-42A9-4F6B-8308-1696026B7848 [10970]
Responsible Process: SimulatorTrampoline [681]

Date/Time:           2022-04-04 08:13:56.8228 +0200
Launch Time:         2022-04-04 08:12:38.1378 +0200
OS Version:          macOS 12.3 (21E230)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000050
Exception Codes: 0x0000000000000001, 0x0000000000000050
VM Region Info: 0x50 is not in any region.  Bytes before following region: 4401176496
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      10654a000-106562000    [   96K] r-x/r-x SM=COW  ...er.app/Runner
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [28708]

Triggered by Thread:  21

Application Specific Information:
CoreSimulator 783.5 - Device: iPhone 13 (8658AF85-42A9-4F6B-8308-1696026B7848) - Runtime: iOS 15.2 (19C51) - DeviceType: iPhone 13
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot

....

Thread 21 Crashed::  Dispatch queue: com.apple.NSURLSession-delegate
0   libdispatch.dylib                   0x7fff20117e5c _dispatch_sync_f + 3
1   Runner                                 0x106559138 -[FlutterDownloaderPlugin URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:] + 808 (FlutterDownloaderPlugin.m:869)
2   CFNetwork                           0x7fff23e164e5 0x7fff23e05000 + 70885
3   libdispatch.dylib                   0x7fff2011265a _dispatch_call_block_and_release + 12
4   libdispatch.dylib                   0x7fff2011383a _dispatch_client_callout + 8
5   libdispatch.dylib                   0x7fff20119e0c _dispatch_lane_serial_drain + 743
6   libdispatch.dylib                   0x7fff2011aa07 _dispatch_lane_invoke + 455
7   libdispatch.dylib                   0x7fff2012557d _dispatch_workloop_worker_thread + 772
8   libsystem_pthread.dylib             0x7fff6da2ffd0 _pthread_wqthread + 326
9   libsystem_pthread.dylib             0x7fff6da2ef57 start_wqthread + 15

Running on the latest stable Flutter version:

[✓] Flutter (Channel stable, 2.10.4, on macOS 12.3 21E230 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.66.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!
PhyoeKo commented 2 years ago

same here when I initialised, await FlutterDownloader.initialize(debug: true);

colorbeach commented 2 years ago

iOS integration requires configuration

JannieT commented 2 years ago

@colorbitch I assumed the example app already had the integration configured in the committed Info.plist and project.pbxproj files. Looks like the docs are a bit outdated so also I tried with adding "Background processing":

Screenshot 2022-04-08 at 16 50 10

but I still get the crash, with or without the "Background processing" mode.

colorbeach commented 2 years ago

@colorbitch I assumed the example app already had the integration configured in the committed Info.plist and project.pbxproj files. Looks like the docs are a bit outdated so also I tried with adding "Background processing":

Screenshot 2022-04-08 at 16 50 10

but I still get the crash, with or without the "Background processing" mode.

Did you configure the AppDelegate file? FlutterDownloaderPlugin should be registered in the AppDelegate file.

JannieT commented 2 years ago

@colorbitch I have cloned the example app in this repository. It is already fully configured by the package authors: https://github.com/fluttercommunity/flutter_downloader/blob/master/example/ios/Runner/AppDelegate.m

kirankumbhar commented 2 years ago

I'm facing the same issue. Crashes on ios Emulator Emulator: iPhone 12 pro max. Mac OS: Catalina

Stardusted1 commented 2 years ago

Same issue on iphone 12

Flutter doctor

[✓] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-arm, locale ru-UA) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] Android Studio [✓] VS Code (version 1.67.2) [✓] Connected device (5 available) [✓] HTTP Host Availability

danielmessi13 commented 2 years ago

Apparently upgrading to beta 3 solves, but I haven't tested it yet.

https://developer.apple.com/forums/thread/683333

bartekpacia commented 1 year ago

Closing because of lack of recent activity. Thanks to everyone who helped find a solution :)