pietervdvn / MapComplete

An easy-to-use webapp to edit OpenStreetMap
https://mapcomplete.org
228 stars 92 forks source link

Panoramax image upload failing on Chrome Android #2202

Open davidpnewton opened 1 month ago

davidpnewton commented 1 month ago

Using 0.47.5 on Android with Chrome and when trying to upload images to Panoramax I'm getting a failed upload message. Same message as was showing up when Imgur image uploads started failing.

0.47.5 on Windows with Chrome allows upload of images to Panoramax and so it appears to be an Android-specific Chrome issue.

thibaultmol commented 1 month ago

Yeah, we are aware of the issue but still trying to figure it out.

From my understanding and debugging from it. It seems like on some phones, if a browser opens an 'image picker', you select the image, try upload. it'll fail. (and then the error behind the scenes will say it's because there is no location in the image). Because some phones strip location from images it seems.

Could you try this workaround: when you click the button to upload a file, click the top right menu and choose browse. and select the image that way

image

image

image

pietervdvn commented 1 month ago

@davidpnewton Would you mind sharing:

If you don't want to share this publicly, please send this to me via the osm messaging system or some other means.

RayBB commented 1 month ago

I recently had a similar issue on my app. On Android I think all browsers strip location if the html of the page is set to upload images. If you set it to upload any file type (or something like that) then it stops stripping location. Tested this on FF and Chrome Android.

thibaultmol commented 1 month ago

also what I observed. using a 'file picker' instead of an 'image picker' solves this problem from my testing. Problem is that the file picker doesn't have an easy 'take picture' button like the image picker does.

@pietervdvn I think maybe settling for the file picker is best. And when you have you have the android package, you can then use the native android image picker which won't have this problem https://github.com/pietervdvn/MapComplete/issues/2112

pietervdvn commented 1 month ago

I tried this with Google Chrome on an older device and could not reproduce this.

@davidpnewton I did make some fixes on dev.mapcomplete.org though, which might fix this. Would you mind testing there too?

davidpnewton commented 1 month ago

Just did. I'm afraid it didn't resolve the issue with the image picker. The file browser method does function as a workaround.

So it does indeed appear to be something funky that the image picker is doing to the pictures v what the file browser does to them.

davidpnewton commented 1 month ago

It's Firefox as well that shows this bug on Android. Definitely looks like an image picker problem. Devtools on Firefox showed this:

Screenshot_20241010_203505_Firefox

pietervdvn commented 1 month ago

Allright, first a mea culpa. I never actually pushed the changes...

Second, I'm not sure the EXIF-data is the problem - the only case that I didn't cover (up till just now) is that if there is no exif data at all and that the EXIF-library crashes on this. I put a try-catch around it to mitigate this, so it might help.

Furthermore, I've added in error reporting code, so it should now "phone home" with the stack trace, so I can peek into the logs without you needing to look peek into the console ;)

BTW: is that some plugin which gives a console in the mobile browser? Which one is it?

davidpnewton commented 1 month ago

"Allright, first a mea culpa. I never actually pushed the changes..."

Oopsie. I'll try again now that you have, really, pushed them!

As for the console on a mobile browser? That's a screenshot of Firefox, and there's a Firefox addon which gives a console for the mobile version.

thibaultmol commented 1 month ago

Oh why didn't this come up when I searched for it before xd really cool: https://addons.mozilla.org/en-US/android/addon/mobidevtools/

thibaultmol commented 1 month ago

v0.47.5 fully cleared data before hand: Screenshot_20241011-124518 Screenshot_20241011-124510

Binnette commented 1 month ago

Same problem on my Android phone with Chrome (or Firefox).

POST on https://panoramax.mapcomplete.org/api/collections/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/items/ returns:

{
    "details": {
        "error": "Coordonnées GPS absentes ou invalides dans les attributs EXIF de l'image"
    },
    "message": "Impossible de lire les métadonnées de la photo",
    "status_code": 400
}

The error is "GPS coors missing or invalid in image EXIF".

So I tried to upload the same image but with Firefox on PC and it works nicely.

So I recorded a "HAR" from my phone and a second "HAR" with the web browser of my PC. Both contains the payload and the image to upload on panoramax. But the image binary are different for the same image (phone vs PC)! I can not compare more, I didn't find a way to properly extract the image from the HAR file...

Also I noticed on phone that:

image

thibaultmol commented 1 month ago

@Binnette do the instructions for using the 2nd option you show work that I showed in the 2nd comment on this issue? clicking the triple dot menu at the top right and choosing browse and selecting the file that way?

Binnette commented 1 month ago

@Binnette do the instructions for using the 2nd option you show work that I showed in the 2nd comment on this issue? clicking the triple dot menu at the top right and choosing browse and selecting the file that way?

Ok it works! Sorry I didn't understand that this procedure was a work around. TY @thibaultmol

davidpnewton commented 1 month ago

https://stackoverflow.com/questions/70865878/picking-photo-from-web-in-android-no-longer-includes-exif-gps-location

This may add a little information about what's going on.

thibaultmol commented 1 month ago

yeah that's what I said to pieter as well. I'm not sure why they're doing that but yeah.

I suggested that when there is a mapcomplete android app (just a wrapper around the website) he'd be able to get around this problem.

and on the regular website just switch to using the regular file picker maybe

pietervdvn commented 1 month ago

yeah that's what I said to pieter as well. I'm not sure why they're doing that but yeah.

Privacy

@Binnette I'd love to receive the HAR-files, especially of the failing upload! You can send it to info@mapcomplete.org

thibaultmol commented 1 month ago

Privacy

Well yeah, but then give an option to the user to disable it stripping it. (I was thinking just now like: why is the camera working for Binnette and then I realized why: it's the samsung galaxy camera app which probably just doesn't do the gps coordinate stripping)

pietervdvn commented 1 month ago

I did an attempt that might improve matters here. @Binnette can you please try again on https://dev.mapcomplete.org ?

Binnette commented 1 month ago

Hi @pietervdvn, without using the workaround I still have the issue on dev instance.

Hedaja commented 4 days ago

I did an attempt that might improve matters here. @Binnette can you please try again on https://dev.mapcomplete.org ?

I unfortunately can confirm that the issue still persists on the latest dev version

Tried it on Android 11 with Firefox 133.0b9.