apps-android-commons
apps-android-commons copied to clipboard
[Bug]: Custom Image Selector not identifing photo location
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
- 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.
- Select the same photo using the "custom selector".
- 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
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!
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.
@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.
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:
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.
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.
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).
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"
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?
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 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.
Oops sorry that error was my fault, specific to my dev branch.
oops again wrong issue...