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

[image_picker: ^1.1.0] Android 12+ image viewer crashes when no images are passed to selected images #147280

Closed
Biowulf21 opened this issue Apr 24, 2024 · 15 comments · Fixed by flutter/packages#6691
Labels
c: crash Stack traces logged to the console c: fatal crash Crashes that terminate the process p: image_picker The Image Picker plugin. P1 High-priority issues at the top of the work list package flutter/packages repository. See also p: labels. platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version team-android Owned by Android platform team triaged-android Triaged by Android platform team

Comments

@Biowulf21
Copy link

Biowulf21 commented Apr 24, 2024

Steps to reproduce

EDIT: I am using the pickMultiImage function

  1. Click button to open image_picker on android 13
  2. Select a single image
  3. Click View Selected on lower left side of screen
  4. Click Selected button to unselect the single image (add button will reflect 0 images selected)
  5. Click add button

Expected results

Image picker should close when this flow is done, as tested on native android applications.

Actual results

The app crashes.

Code sample

try {
      final picker = ImagePicker();
      final permissionStatus =
          await ImagesUtils.getPhotoPickingPermissionStatus(source);

      if (permissionStatus.isGranted || permissionStatus.isLimited) {
        final image = await picker.pickImage(source: source);
}

} catch (e){
print(e);
}

Screenshots or Video

1000000085

Logs

Logs
E/AndroidRuntime(25551): java.lang.NullPointerException: uri
E/AndroidRuntime(25551): 	at java.util.Objects.requireNonNull(Objects.java:232)
E/AndroidRuntime(25551): 	at android.content.ContentResolver.openInputStream(ContentResolver.java:1511)
E/AndroidRuntime(25551): 	at io.flutter.plugins.imagepicker.FileUtils.getPathFromUri(FileUtils.java:55)
E/AndroidRuntime(25551): 	at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleChooseMultiImageResult(ImagePickerDelegate.java:707)
E/AndroidRuntime(25551): 	at io.flutter.plugins.imagepicker.ImagePickerDelegate.lambda$onActivityResult$1$io-flutter-plugins-imagepicker-ImagePickerDelegate(ImagePickerDelegate.java:609)
E/AndroidRuntime(25551): 	at io.flutter.plugins.imagepicker.ImagePickerDelegate$$ExternalSyntheticLambda1.run(Unknown Source:6)
E/AndroidRuntime(25551): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/AndroidRuntime(25551): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/AndroidRuntime(25551): 	at java.lang.Thread.run(Thread.java:1012)
I/ViewRootImpl@c3d471f[MainActivity](25551): MSG_WINDOW_FOCUS_CHANGED 1 0
D/ViewRootImpl@c3d471f[MainActivity](25551): mThreadedRenderer.initializeIfNeeded()#2 mSurface={isValid=true 0xb4000073ea96d390}
D/InputMethodManagerUtils(25551): startInputInner - Id : 0
I/InputMethodManager(25551): startInputInner - IInputMethodManagerGlobalInvoker.startInputOrWindowGainedFocus
I/Process (25551): Sending signal. PID: 25551 SIG: 9
Lost connection to device.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.5, on macOS 13.6.1 22G313 darwin-arm64, locale en-PH)
    • Flutter version 3.19.5 on channel stable at /Users/jamespatrickjilhaney/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (4 weeks ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/jamespatrickjilhaney/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.14.2

[✓] 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)

[✓] VS Code (version 1.88.0)
    • VS Code at /Users/jamespatrickjilhaney/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.86.0

[✓] Connected device (4 available)
    • SM G996N (mobile)                   • R3CR1068VDD                          • android-arm64  • Android 14 (API 34)
    • iPhone SE (3rd generation) (mobile) • BE33B77B-5993-4F32-807B-1CB29C0F7C13 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)                     • macos                                • darwin-arm64   • macOS 13.6.1 22G313 darwin-arm64
    • Chrome (web)                        • chrome                               • web-javascript • Google Chrome 119.0.6045.105

[✓] Network resources
    • All expected network resources are available.
@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label Apr 24, 2024
@danagbemava-nc
Copy link
Member

Hi @Biowulf21, is this the only device you're seeing it on or are other devices affected? I tested this on my pixel 7 running android 14 and it doesn't allow me to submit 0 items.

Can you also try uprading to the latest version of image_picker to see if you still experience this issue?

Thank you

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 24, 2024
@Biowulf21
Copy link
Author

Biowulf21 commented Apr 26, 2024

Hi @Biowulf21, is this the only device you're seeing it on or are other devices affected? I tested this on my pixel 7 running android 14 and it doesn't allow me to submit 0 items.

Can you also try uprading to the latest version of image_picker to see if you still experience this issue?

Thank you

hi @danagbemava-nc , I tested this on my Samsung S21+ and it crashes the app as well. Huawei P30 Pro also crashes per our QA team.

I'll look into the latest version next week. Thank you!

EDIT: Corrected the device models

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 26, 2024
@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 29, 2024
@danagbemava-nc
Copy link
Member

danagbemava-nc commented Apr 29, 2024

Please keep us updated

@Biowulf21, just to confirm, are you calling pickImage or pickMultiImage? On my pixel 7, with pickImage, there isn't the option to select multiple images, but pickMultiImage does allow me to select multiple images.

@Biowulf21
Copy link
Author

Biowulf21 commented Apr 29, 2024

Hi @danagbemava-nc I'm using pickMultiImage. So sorry for the delay, I'm out of the house right now, but I'll be sure to update this thread later tonight. Thank you!

Edit: I tested the same flow using the latest image_pickers version (1.1.0) and the issue is still there.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 29, 2024
@Biowulf21 Biowulf21 changed the title [image_picker: ^1.0.4] Android 13 image viewer crashes when no images are passed to selected images [image_picker: ^1.1.0] Android 13 image viewer crashes when no images are passed to selected images Apr 29, 2024
@danagbemava-nc
Copy link
Member

Thanks for the update. Just to confirm, were the samsung s21+ and the huawei p40 both running android 13? Have you tested this on any other OS version?

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 30, 2024
@Biowulf21
Copy link
Author

Biowulf21 commented May 2, 2024

Thanks for the update. Just to confirm, were the samsung s21+ and the huawei p40 both running android 13? Have you tested this on any other OS version?

Hello, my team and I tested this on three devices: Huawei P30 Pro (Android 12), Infinix SMART 8 (Android 13), and Samsung 21+ (Android 14).

I also updated the title of the issue for your reference @danagbemava-nc. Sorry for the confusion.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 2, 2024
@Biowulf21 Biowulf21 changed the title [image_picker: ^1.1.0] Android 13 image viewer crashes when no images are passed to selected images [image_picker: ^1.1.0] Android 12+ image viewer crashes when no images are passed to selected images May 2, 2024
@danagbemava-nc
Copy link
Member

Thanks for the update.

While I cannot reproduce this on my device (the picker won't allow sending back 0 items), it seems like we are passing a null URI to https://github.com/flutter/packages/blob/6e6082660b73144e5fedf28545602c1ef6588f8e/packages/image_picker/image_picker_android/android/src/main/java/io/flutter/plugins/imagepicker/FileUtils.java#L55

I think it would be best to catch the null_pointer exception or check if the uri is null before processing.

Labeling for further insight.

@danagbemava-nc danagbemava-nc added c: crash Stack traces logged to the console platform-android Android applications specifically p: image_picker The Image Picker plugin. package flutter/packages repository. See also p: labels. c: fatal crash Crashes that terminate the process team-android Owned by Android platform team fyi-ecosystem For the attention of Ecosystem team and removed in triage Presently being triaged by the triage team labels May 2, 2024
@Jackson-Antunes-Sampaio

This comment was marked as off-topic.

@kvn-DN

This comment was marked as off-topic.

@stuartmorgan stuartmorgan added the triaged-ecosystem Triaged by Ecosystem team label May 8, 2024
@flutter-triage-bot flutter-triage-bot bot removed fyi-ecosystem For the attention of Ecosystem team triaged-ecosystem Triaged by Ecosystem team labels May 8, 2024
@stuartmorgan
Copy link
Contributor

This looks like the same issue that flutter/packages#4836 fixed for single-item selection, where some pickers are, instead of returning no clip data, returning clip data with a null URI. It's not fixed for the multi-item codepath yet (see flutter/packages#4836 (comment) for a suggestion on this).

@reidbaker reidbaker added P1 High-priority issues at the top of the work list triaged-android Triaged by Android platform team labels May 9, 2024
@danagbemava-nc danagbemava-nc added the r: fixed Issue is closed as already fixed in a newer version label May 13, 2024
@stuartmorgan
Copy link
Contributor

Re-opening since the PR didn't fix all codepaths. And in particular, the original report's stack is in handleChooseMultiImageResult, which is the one that's not fixed.

@Mairramer
Copy link
Contributor

@stuartmorgan @gmackall I created a new PR complementing the one I had previously sent.

@LouiseHsu
Copy link
Contributor

i don't remember closing this?

@gmackall
Copy link
Member

i don't remember closing this?

I think its just a Github bug, I believe updating the main branch on a fork (maybe only with the github ui?) will sometimes re-close an issue when that update pulls in a commit that contains the description "fixes #issue number".

So if a commit gets merged to main saying "fixed..." but then the issue gets re-opened, and then you update your main branch (and pull in the commit) it will sometimes re-close.

@danagbemava-nc danagbemava-nc removed the r: fixed Issue is closed as already fixed in a newer version label May 14, 2024
@gmackall
Copy link
Member

This should be fixed by flutter/packages#5009

@danagbemava-nc danagbemava-nc added the r: fixed Issue is closed as already fixed in a newer version label May 15, 2024
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this issue May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: crash Stack traces logged to the console c: fatal crash Crashes that terminate the process p: image_picker The Image Picker plugin. P1 High-priority issues at the top of the work list package flutter/packages repository. See also p: labels. platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version team-android Owned by Android platform team triaged-android Triaged by Android platform team
Projects
None yet
9 participants