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

[iOS] File Picker sometimes crashes when you swipe the modal down and call it again #1357

Closed
1 of 4 tasks
chapsan2001 opened this issue Aug 25, 2023 · 8 comments · May be fixed by #1529
Closed
1 of 4 tasks

[iOS] File Picker sometimes crashes when you swipe the modal down and call it again #1357

chapsan2001 opened this issue Aug 25, 2023 · 8 comments · May be fixed by #1529
Labels
new issue An issue that hasn't yet been seen from the maintainer stale

Comments

@chapsan2001
Copy link

Describe the bug
When user closes the native bottom sheet by swiping it down, FilePicker.platform.pickFiles sometimes does not complete. It leads to PlatformException and crash when you try to call it again. You have to close the sheet quickly and quickly tap the button again. Package version is 5.3.3 which is the latest

Similar issue seems to be fixed earlier (in version 4.1.1) - Link. Seems to be a regression.

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
iOS 16.5

How are you picking?

import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: FilePicker.platform.pickFiles,
            child: const Text('Pick File'),
          ),
        ),
      ),
    );
  }
}

Error Log

flutter: [MethodChannelFilePicker] Platform exception: PlatformException(multiple_request, Cancelled by a second request, null, null)
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(multiple_request, Cancelled by a second request, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
<asynchronous suspension>
#2      MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:496:35)
<asynchronous suspension>
#3      FilePickerIO._getPath (package:file_picker/src/file_picker_io.dart:92:33)
<asynchronous suspension>



***** FilePicker canceled
* -[FilePickerPlugin documentPickerWasCancelled:] [Line 635]
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x00000001026c0760 file_picker`-[FilePickerPlugin documentPickerWasCancelled:](self=0x0000000280e301e0, _cmd="documentPickerWasCancelled:", controller=0x0000000102744630) at FilePickerPlugin.m:636:5
   633 	#ifdef PICKER_DOCUMENT
   634 	- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
   635 	    Log(@"FilePicker canceled");
-> 636 	    _result(nil);
    	    ^
   637 	    _result = nil;
   638 	    [controller dismissViewControllerAnimated:YES completion:NULL];
   639 	}
Target 0: (Runner) stopped.

Screenshots and/or video
https://github.com/miguelpruivo/flutter_file_picker/assets/59578374/a3abaa83-a36e-4fc7-a771-bab7fd484866

Flutter Version details

[✓] Flutter (Channel stable, 3.13.0, on macOS 12.6 21G115 darwin-arm64, locale ru-RU)
    • Flutter version 3.13.0 on channel stable at /Users/chapsan2001/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision efbf63d9c6 (9 days ago), 2023-08-15 21:05:06 -0500
    • Engine revision 1ac611c64e
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/chapsan2001/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • ANDROID_HOME = /Users/chapsan2001/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] Connected device (4 available)
    • SM G970F (mobile)            • adb-RF8M2030CZT-ET5x2j._adb-tls-connect._tcp. • android-arm64  • Android 12 (API 31)
    • iPhone 13 mini #772 (mobile) • 00008110-000938991E9B801E                     • ios            • iOS 16.5 20F66
    • macOS (desktop)              • macos                                         • darwin-arm64   • macOS 12.6 21G115 darwin-arm64
    • Chrome (web)                 • chrome                                        • web-javascript • Google Chrome 116.0.5845.110

[✓] Network resources
    • All expected network resources are available.

• No issues found!

@chapsan2001 chapsan2001 added the new issue An issue that hasn't yet been seen from the maintainer label Aug 25, 2023
@nguyenkhaimegatron
Copy link

same issue

@github-actions
Copy link

github-actions bot commented Sep 6, 2023

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Sep 6, 2023
@chapsan2001
Copy link
Author

any news on the issue?

@github-actions github-actions bot removed the stale label Sep 16, 2023
@github-actions
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Sep 24, 2023
@kreativityapps
Copy link

Hi,

Please have a look at my change: kreativityapps@2387c78

The important part is CustomDocumentPickerViewController, a subclass of UIDocumentPickerViewController that overrides the viewDidDisappear method, making sure that documentPickerWasCancelled is called when no file is selected, even when the bottom sheet is suddenly swiped down.
In documentPickerWasCancelled I added additional checks, but the root cause is that documentPickerWasCancelled was not called before.

@github-actions github-actions bot removed the stale label Oct 1, 2023
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Oct 9, 2023
@github-actions
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

@Maatteogekko
Copy link

Maatteogekko commented Jun 4, 2024

This issue is still present in 8.0.3 version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue An issue that hasn't yet been seen from the maintainer stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants