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

App crashes if both image_picker and file_picker 1.3.0 are installed #48

Closed
repetitions opened this issue Mar 13, 2019 · 5 comments
Closed

Comments

@repetitions
Copy link

repetitions commented Mar 13, 2019

The file_picker appears to be working fine, but any attempt to use the image_picker causes the app to crash, which will happen after a file is selected or captured by the camera, or when the user cancels selection or capture.

D/AndroidRuntime(12668): Shutting down VM
E/AndroidRuntime(12668): FATAL EXCEPTION: main
E/AndroidRuntime(12668): Process: app, PID: 12668
E/AndroidRuntime(12668): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2343, result=-1, data=Intent { }} to activity {MainActivity}: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(12668): at android.app.ActivityThread.deliverResults(ActivityThread.java:4126)
E/AndroidRuntime(12668): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4169)
E/AndroidRuntime(12668): at android.app.ActivityThread.-wrap20(ActivityThread.java)
E/AndroidRuntime(12668): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1552)
E/AndroidRuntime(12668): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(12668): at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(12668): at android.app.ActivityThread.main(ActivityThread.java:6186)
E/AndroidRuntime(12668): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12668): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
E/AndroidRuntime(12668): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
E/AndroidRuntime(12668): Caused by: java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(12668): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:124)
E/AndroidRuntime(12668): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:209)
E/AndroidRuntime(12668): at com.mr.flutter.plugin.filepicker.FilePickerPlugin$1.onActivityResult(FilePickerPlugin.java:85)
E/AndroidRuntime(12668): at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:218)
E/AndroidRuntime(12668): at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:143)
E/AndroidRuntime(12668): at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:142)
E/AndroidRuntime(12668): at android.app.Activity.dispatchActivityResult(Activity.java:6937)
E/AndroidRuntime(12668): at android.app.ActivityThread.deliverResults(ActivityThread.java:4122)

@miguelpruivo
Copy link
Owner

Hi. This is quite weird since they aren’t related in any way at the moment.

Can you described the steps to fully reproduce this? Does it happen on both platforms?

Thank you.

@repetitions
Copy link
Author

Hi, here are the steps to reproduce:

  1. Add both image_picker and file_picker to your dependencies.
  2. Make a call to ImagePicker.pickImage()

The app will stop the moment a file is selected or cancelled.

I currently running on Android only, so I'm not sure if this happens on iOS.

@miguelpruivo
Copy link
Owner

miguelpruivo commented Mar 13, 2019

Somehow, I'm glad that you've experienced this issue so quickly as it could lead some other users to come across this exception. A result callback was trying to be invoked when it shouldn't.

It was a minor fix, yet important. If you are using ^1.3.0 clean & update packages so it fetches the 1.3.1 that is now on dart pub. You should be fine now, nevertheless, let me know if it fixed for you.

Thank you.

@repetitions
Copy link
Author

It's working perfectly now. Thank you for your prompt response and pushing out a fix so quickly.

@saurabhdtu
Copy link

saurabhdtu commented May 13, 2021

Getting this exception

java.lang.IllegalStateException: Reply already submitted
        at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:155)
        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:238)
        at com.mr.flutter.plugin.filepicker.FilePickerPlugin$MethodResultWrapper$1.run(FilePickerPlugin.java:214)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

This is my code

Container(
              height: 128.0,
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(10.0),
                      topRight: Radius.circular(10.0))),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    InkWell(
                        onTap: () async {
                          FilePickerResult result = await FilePicker.platform
                              .pickFiles(
                                  allowMultiple: true,
                                  type: FileType.custom,
                                  allowedExtensions: ['pdf']);
                          if (result != null) {
                            List<File> files =
                                result.paths.map((path) => File(path)).toList();
                            chooserCallback.filesChosen(files);
                            Navigator.of(buildContext).pop();
                          } else {
                            chooserCallback.error("No pdf files selected");
                          }
                        },
                        child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              SvgPicture.asset(
                                  "${assetImage}ic_health_claim_pdf.svg")
                            ])),
                    InkWell(
                        onTap: () async {
                          FilePickerResult result = await FilePicker.platform
                              .pickFiles(
                                  allowMultiple: true,
                                  type: FileType.image);
                          if (result != null) {
                            List<File> files =
                                result.paths.map((path) => File(path)).toList();
                            chooserCallback.filesChosen(files);
                            Navigator.of(buildContext).pop();
                          } else {
                            chooserCallback.error("No images selected");
                          }
                        },
                        child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              SvgPicture.asset(
                                  "${assetImage}ic_health_claim_gallery.svg")
                            ])),
                    InkWell(
                        onTap: () async {
                          List<Media> res = await ImagesPicker.openCamera(
                              pickType: PickType.image, quality: 0.8);
                          if (res.isNotEmpty) {
                            List<File> files =
                                res.map((media) => File(media.path)).toList();
                            chooserCallback.filesChosen(files);
                            Navigator.of(buildContext).pop();
                          } else {
                            chooserCallback.error("No images captured");
                          }
                        },
                        child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              SvgPicture.asset(
                                  "${assetImage}ic_health_claim_camera.svg")
                            ]))
                  ]));
        });

I am using file_picker: 3.0.1 & images_picker: 1.2.4
Crash happens for large files >40MB or if large number of files are selected. I tried removing the images_picker library but even then the crash occurs. Its very frequent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants