apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

[Bug]: Custom Image Selector not identifing photo location

Open mds08011 opened this issue 2 years ago • 7 comments

Summary

The "custom picture selector" is not recognizing the locations from my photo's EXIF data. If I upload a photo using the regular file selctor, the app is able to identify the location of the photo from EXIF data. If I select the same photo with the custom selector, I get a "no location found" dialog box.

By "regular selector," I am referring to the button highlighted by a green box in the image below. "Custom selector" is in the red box.

(Not totally sure I have the name correct, but this is the feature I am referring to: https://github.com/commons-app/apps-android-commons/issues/4764)

Steps to reproduce

  1. Select a photo known to have associated location data using the "regular selector". Note whether the app is able to idenfiy the image's location.
  2. Select the same photo using the "custom selector".
  3. The app indicates that no location is found.

Expected behaviour

Expected to identify location from EXIF data.

Actual behaviour

App indicates no location is found for the photo.

Device name

Google Pixel 4a

Android version

Android 12

Commons app version

4.0.1

Device logs

I didn't capture logs but can reproduce if they would be helpful.

Screen-shots

Image selected with custom picker does not identify location:

The same photo via the regular image selector identifies a location:

Would you like to work on the issue?

Prefer not

mds08011 avatar Jul 17 '22 08:07 mds08011

Thanks for reporting! I have experienced a rather similar problem, always on Pixel 4, and never with my old Samsung somehow. If you have access to other phones, would you mind trying?

Does sharing from Google Photos work? And what about from a third-party gallery app? Thanks!

nicolas-raoul avatar Jul 19 '22 08:07 nicolas-raoul

I don't have another phone easily available but I'll see what I can dig up.

Sharing from Google Photos works without issue, but sharing from a third-party image gallery (Solid Explorer's "SE Image Viewer" in my case) has the same problem identifying image location.

mds08011 avatar Jul 19 '22 17:07 mds08011

@sivaraam , would you mind trying to reproduce this issue on your OnePlus Nord?

Checking whether image locations are identified when sharing photos from a third-party image gallery and/or using the Custom Photo Selector.

mds08011 avatar Jul 21 '22 14:07 mds08011

From third-party gallery (Simple Gallery, by Simple Mobile Tools), I share to:

  • EXIF Viewer: It shows coordinates
  • Commons app: It tells me "no location found"

Screencast: https://youtu.be/-azE7U-lGgA

Pixel 4, picture taken using stock camera

Then when I share the same picture from the Google Photos app, the Commons app finds the location: Screenshot_20220806-151942

nicolas-raoul avatar Aug 06 '22 06:08 nicolas-raoul

Apologies. I somehow happened to miss the ping here.

@sivaraam , would you mind trying to reproduce this issue on your OnePlus Nord?

Checking whether image locations are identified when sharing photos from a third-party image gallery and/or using the Custom Photo Selector.

Sure. I tried to check but I'm facing a somewhat weird situation. The app doesn't seem to be considering the location information in any of the images I try to upload i.e., I get the "No location found" pop-up in all cases though the image has location information in it. I tried to use regular upload option / custom image selector and sharing to the app from gallery app. All have consistent results.

Not sure why this is happening. I don't remember it being like this before. I'm using v4.0.3.~23c474b06 on OnePlus Nord that runs Android 12. I've checked that the "Location" checkbox is turned on in the "Manage EXIF tags" setting.

sivaraam avatar Aug 21 '22 17:08 sivaraam

I would like to mention that I am also experiencing this issue on my Moto G50 running Android 12. Location works as expected on the "regular" selector but not the custom selector.

Bongo50 avatar Aug 26 '22 12:08 Bongo50

I did some experiments using a picture that has location (proved by ExifViewer app).

At presenter.receiveImage(uploadableFile, place) in UploadMediaDetailFragment.java, uploadableFile's file points to /data/user/0/fr.free.nrw.commons/cache/CommonsContributions/9886dd0c-bf3f-41bb-83a6-9aa5eaff20d3.jpg (or similar) which contains 0,0 as EXIF location (downloaded via Device File Explorer then analyzed with exif command line tool)

Using the "normal" picker, at the same breakpoint, uploadableFile's file points to a jpg which contains a real (non-zero) EXIF location.

Both normal picker and custom picker go via receiveInternalSharedItems

The intent is sent by methods called from onPictureReturnedFromCustomSelector whose data argument contains an Image object whose path is /storage/emulated/0/DCIM/Camera/PXL_20220921_005652237.jpg which has correct EXIF coordinates (even for custom picker) as seen by the EXIF tool after download using Android Studio's Device File Explorer.

Anyone willing to help: It could be interesting to check what happened in older versions of the app, in both custom and not (and maybe also in Android 8 where I did not observe this issue).

nicolas-raoul avatar Oct 09 '22 00:10 nicolas-raoul

https://commonsware.com/Q/pages/chap-location-002.html :

"in Android 10, access to [EXIF location] is much more restricted than it had been."

"only option appears to be to get the Uri for each individual image and use ExifInterface"

nicolas-raoul avatar Oct 29 '22 03:10 nicolas-raoul

On branch https://github.com/commons-app/apps-android-commons/tree/location-loss I did an experiment following https://developer.android.com/training/data-storage/shared/media#media-location-permission

I added the ACCESS_MEDIA_LOCATION permission to the manifest. I also requested the permission at runtime as it is also required but no permission dialog is shown, apparently it is normal: https://stackoverflow.com/a/74288314/226958.

Then in FilePicker.getFilesFromGalleryPictures I got Intent.getClipData().getItemAt(0).getUri() and passed it to ExifInterface.getLatLong(), unfortunately the result is null for a picture that Google Photos shows has a location.

Any idea what I might be missing?

nicolas-raoul avatar Nov 02 '22 12:11 nicolas-raoul

Any idea what I might be missing?

I'm not absolutely sure but maybe you missed the following point mentioned in the article ?

Your app needs to call MediaStore.setRequireOriginal(), supplying the Uri for which you would like the location — this method then returns a decorated Uri that can be used with openInputStream()

sivaraam avatar Nov 07 '22 18:11 sivaraam

@sivaraam you are right! I added setRequireOriginal and now I get Calling uid does not have permission to access picker uri: content://media/picker/0/com.android.providers.media.photopicker/media/1000032383?requireOriginal=1. If I understand https://issuetracker.google.com/issues/243294058#comment6 correctly, ACTION_PICK_IMAGES not giving EXIF location in "Working as Intended". 😱

We need to also try with the sharing intent and custom picker.

nicolas-raoul avatar Nov 09 '22 13:11 nicolas-raoul

Oops sorry that error was my fault, specific to my dev branch.

nicolas-raoul avatar Nov 15 '22 13:11 nicolas-raoul

oops again wrong issue...

nicolas-raoul avatar Nov 15 '22 13:11 nicolas-raoul