Skip to content

[image_picker] NPE On Permission error. #108334

Description

@ajzome

Steps to Reproduce

I have thus far been unable to reproduce the error locally, however I do occasionally see reports from users. The problem seems to come from an error during the permissions check. Based on the stack trace I have located the bug in ImagePickerCache::saveResult (ImagePickerCache.java). After creating the set it does an addAll of paths. However paths is nullable but addAll does not handle null parameters. Null is passed in via ImagePickerDelegate::finishWithError which happens in a few spots

Expected results:

No NPE

Actual results:

An NPE during various errors in the ImagePickerDelegate.

Activity

  1. changed the title [-]NPE On Permission error.[/-] [+][image_picker] NPE On Permission error.[/+] on Jul 26, 2022
  2. danagbemava-nc commented on Jul 26, 2022

    @danagbemava-nc
    Member

    Hi @ajzome, what devices experience the NPE?

    Please also share the complete stacktrace, the version of image_picker that is used as well as the version of flutter used to deploy the app.

    Thank you

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 26, 2022
  4. ajzome commented on Jul 28, 2022

    @ajzome
    Author

    The devices we have hits so far are:
    Motorola Lenovo K11
    Samsung Galaxy J5 Pro
    Lenovo Tab M10 (FHD)
    Redmi 8A

    Stacktrace:
    Caused by: java.lang.NullPointerException: 
      at java.util.AbstractCollection.addAll (AbstractCollection.java:343)
      at io.flutter.plugins.imagepicker.ImagePickerCache.saveResult (ImagePickerCache.java:5)
      at io.flutter.plugins.imagepicker.ImagePickerDelegate.finishWithError (ImagePickerDelegate.java:7)
      at io.flutter.plugins.imagepicker.ImagePickerDelegate.onRequestPermissionsResult (ImagePickerDelegate.java:43)
      at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onRequestPermissionsResult (FlutterEngineConnectionRegistry.java:20)
      at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onRequestPermissionsResult (FlutterEngineConnectionRegistry.java:20)
      at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onRequestPermissionsResult (FlutterActivityAndFragmentDelegate.java:59)
      at io.flutter.embedding.android.FlutterActivity.onRequestPermissionsResult (FlutterActivity.java:10)
      at com.zomecorp.zome.MainActivity.onRequestPermissionsResult (MainActivity.java:17)
      at android.app.Activity.dispatchRequestPermissionsResult (Activity.java:7991)
      at android.app.Activity.dispatchActivityResult (Activity.java:7813)
      at android.app.ActivityThread.deliverResults (ActivityThread.java:4703)
      at android.app.ActivityThread.handleSendResult (ActivityThread.java:4752)
      at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:49)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1993)
      at android.os.Handler.dispatchMessage (Handler.java:106)
      at android.os.Looper.loop (Looper.java:216)
      at android.app.ActivityThread.main (ActivityThread.java:7266)
      at java.lang.reflect.Method.invoke (Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)
    
  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 28, 2022
  6. danagbemava-nc commented on Jul 28, 2022

    @danagbemava-nc
    Member

    Hi @ajzome, what versions of android are the devices running on?

    Please also provide the output of flutter doctor -v as well as the version of image_picker used.

    Thank you

  7. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 28, 2022
  8. ajzome commented on Jul 28, 2022

    @ajzome
    Author

    I do not understand why you need all this information. There is an obvious issue in the java code that I have pointed out.

  9. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 28, 2022
  10. danagbemava-nc commented on Jul 29, 2022

    @danagbemava-nc
    Member

    Hi @ajzome, it is part of our triage process to collect that information. It makes it easier for us to see where to start investigating. Since you cannot reproduce the issue locally, this is more relevant.

    Thank you

  11. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 29, 2022
  12. github-actions commented on Aug 19, 2022

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
    Thanks for your contribution.

  13. added
    r: timeoutIssue is closed due to author not providing the requested details in time
    on Aug 19, 2022
  14. 8 remaining items

  15. added
    a: productionIssues experienced in live production apps
    and removed
    in triagePresently being triaged by the triage team
    on Aug 23, 2022
  16. added
    P2Important issues not at the top of the work list
    on Aug 25, 2022
  17. added
    P1High-priority issues at the top of the work list
    and removed
    P2Important issues not at the top of the work list
    on Nov 3, 2022
  18. RustamG commented on Dec 27, 2022

    @RustamG

    In my case the crash happens when the other plugin requests the permissions (bluetooth) with the same REQUEST_CODE (2345).

  19. gnprice commented on Mar 16, 2023

    @gnprice
    Member

    This was fixed just now by @JeroenWeener in flutter/packages#3448 .

  20. github-actions commented on Mar 31, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  21. locked as resolved and limited conversation to collaborators on Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: productionIssues experienced in live production appsc: crashStack traces logged to the consolep: image_pickerThe Image Picker plugin.packageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions