miguelpruivo / flutter_file_picker

File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
MIT License
1.36k stars 677 forks source link

Xcode 12 / iOS 14 / image pick (single and multiple) / from image_picker #65995 #407

Closed monsieurtanuki closed 4 years ago

monsieurtanuki commented 4 years ago

Describe the bug cf. https://github.com/flutter/flutter/issues/65995 I created a brand new project from scratch and I still get the following message:

Picker Unavailable
There was an error while preparing the picker.
Please try later again

Issue details

  1. Android Studio 4.0.1
  2. file_picker: ^2.0.1+1
  3. Xcode 12 / iOS 14
  4. tried on iOS Simulator iPhone 8 Plus, iPhone 11 Pro Max and iPad Pro (12.9-inch) - 4th generation
  5. same issue with FilePicker.platform.pickFiles(type: FileType.image) and FilePicker.platform.pickFiles(type: FileType.image, allowMultiple: true)
  6. A simple app from scratch

Screenshots and/or video

Screenshot ![Simulator Screen Shot - iPhone 8 Plus - 2020-09-23 at 12 22 42](https://user-images.githubusercontent.com/11576431/94000730-dc87d580-fd97-11ea-8317-2b2245363c95.png)

Flutter Version details

flutter doctor -v ``` [✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.5 19F101, locale fr-FR) • Flutter version 1.20.4 at /Users/fabricefontaine/development/flutter • Framework revision fba99f6cf9 (9 days ago), 2020-09-14 15:32:52 -0700 • Engine revision d1bc06f032 • Dart version 2.9.2 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/fabricefontaine/Library/Android/sdk • Platform android-30, build-tools 30.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.0, Build version 12A7209 • CocoaPods version 1.9.3 [✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 49.0.2 • Dart plugin version 193.7547 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) [✓] Connected device (1 available) • iPhone 8 Plus (mobile) • 755F3CBA-6DA9-4C91-B05A-2CD42DF86E65 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator) • No issues found! ```
tneotia commented 4 years ago

I ran with Xcode to debug and it pointed out these lines as where the exception occurred:

- (void) handleResult:(id) files {
    _result([FileUtils resolveFileInfo: [files isKindOfClass: [NSArray class]] ? files : @[files] withData:self.loadDataToMemory]);
    _result = nil;
}

with error #0 0x000000010baa352a in -[FilePickerPlugin handleResult:] at /Users/tanay/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.6/ios/Classes/FilePickerPlugin.m:271

and

dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
        [self handleResult:urls];
    });

with error #1 0x000000010baa488e in __44-[FilePickerPlugin picker:didFinishPicking:]_block_invoke.303 at /Users/tanay/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.0.6/ios/Classes/FilePickerPlugin.m:406

In FilePickerPlugin.m

Sorry if this is useless, as I said earlier I don't have any experience with debugging Swift and such. If this seems like an error due to this plugin, I can help debug anything else you would like. If not, I assume it is an iOS issue? Can't understand how this would be specific to my app but maybe it is?

miguelpruivo commented 4 years ago

@tneotia can you try reproduce it with the example app?

tneotia commented 4 years ago

Yep I mentioned above in an edit that it was reproducible on example as well

miguelpruivo commented 4 years ago

@tneotia well, I'll take a look as soon as I have the time, but this seems like low priority for me as it should be just worker threads conflicting due to multiple calls to the picker — I don't actually think an user will try to do so and if he does, shouldn't fear undesired behaviors (this also happens sometimes if you brute force some feature in any app/OS 😄).

Nevertheless, I'd be happy to take care of it and make it even better.

Thank you!

tneotia commented 4 years ago

Oh I see. No problem, for me its not really a blocker since the user isn't going to be spamming the images, just something I found while testing a build. Take your time with this, and if you need anything else let me know!