zulip / zulip-mobile

Zulip mobile apps for Android and iOS.
https://zulip.com/apps/
Apache License 2.0
1.3k stars 654 forks source link

Uploaded photos can get wrong orientation #3583

Closed gnprice closed 4 years ago

gnprice commented 5 years ago

UPDATE: Following the investigation below, this was folded into the server-side issue zulip/zulip#8177 .


A user reports:

Photos uploaded on mobile are a "raw" orientation, which if a photo was taking "portrait" means it's presented in "landscape" causing whiplash. This doesn't seem to occur on the Desktop.

In quick testing, I don't reproduce this:

That's on both Android and iOS, on v26.0.123.

Not sure what variable is different between my attempted repro and the user seeing the issue. One thing to try would be to take the photo from the camera app, then upload it from the camera roll, rather than taking it directly from the Zulip app.

gnprice commented 5 years ago

The user adds:

Android- and reportedly also iPhone- users who take a photo, and then add it to a Zulip conversation don't have the photo orientation "adjusted" (screenshot attached). If that same picture is sent to a desktop, e.g. by way of Google Drive and uploaded with the Desktop client, the orientation is correct. Sequence: Zulip Mobile Client, "+" -> image select -> choose a previously taken photo in "portrait" orientation (or "landscape" if you took it "upside down").

(The screenshot showed a Zulip message, I think from the web/desktop app, with a photo that is clearly rotated 90deg from life. The image has the sky to the left and the ground to the right. Its size in the sky-ground axis is longer than the other -- i.e. its proper orientation is portrait -- and it's displayed with that long axis as the width, i.e. in landscape.)

I tried this exact repro just now, on v26.1.124 on my Pixel 2 XL running Android 9:

Sequence: Zulip Mobile Client, "+" -> image select -> choose a previously taken photo in "portrait" orientation

and it didn't reproduce, though -- the real-life top of the photo displays at the top.

Also tried two variations on how to take the photo (in each case, taking it from the camera app and then in Zulip using "+" -> "photo" icon to select and upload it):

Neither of those reproduced it either -- the real-life top of the photo displayed at the top each time.

So, still some unknown variable involved.

jainkuniya commented 5 years ago

I am also not able to reproduce it. Tried uploading images from gallery and taking images from camera in both the orientation, and image is uploaded in the right orientation.

We need to ask user for video/GIF of reproducing this issue, it will help a lot. Also on which device he is facing this issue?

gnprice commented 5 years ago

Thanks @jainkuniya ! Would you add details of what device model, what OS version, and what Zulip version you were using in the attempted repro?

cognusion commented 5 years ago

Confirmed Correct: iPhone 6, iOS 12.3, 12.4; Samsung Phones of numerous flavors Confirmed Incorrect: MotoZ3, Android 8,9; MotoZ2, Android 8; iPhone 6, iOS 12.1.4

gnprice commented 5 years ago

@cognusion Very interesting, thanks!

Would you say a bit more about what you observed? In particular, on these devices:

Confirmed Incorrect: MotoZ3, Android 8,9; MotoZ2, Android 8; iPhone 6, iOS 12.1.4

is it the case that you hit this issue every time you try? If so, that seems like a very helpful clue.

Oh another detail that would potentially be quite helpful:

Confirmed Correct: ..., Samsung Phones of numerous flavors

Could you track down the OS version and/or device model of one or two of these phones? (And I believe you're saying that on these devices, you've tried uploading photos and you don't see the symptoms of this issue.)

cognusion commented 5 years ago

@cognusion Very interesting, thanks!

Would you say a bit more about what you observed? In particular, on these devices:

Confirmed Incorrect: MotoZ3, Android 8,9; MotoZ2, Android 8; iPhone 6, iOS 12.1.4

Photos taken on those devices using the phone camera in a "portrait" orientation, and then uploaded using the Zulip Mobile client, are shown in "landscape" as described. I'm not using the in-Zulip "take a photo", rather the gallery for previously-taken photos.

Also, of note, downloading a portrait picture onto the phone from somewhere, and then uploading it to Zulip Mobile does not result in the "landscaping". Also, uploading the portrait picture using the Zulip Desktop client does not result in the "landscaping".

is it the case that you hit this issue every time you try? If so, that seems like a very helpful clue.

Yes, 100% reproducible.

Oh another detail that would potentially be quite helpful:

Confirmed Correct: ..., Samsung Phones of numerous flavors

Could you track down the OS version and/or device model of one or two of these phones? (And I believe you're saying that on these devices, you've tried uploading photos and you don't see the symptoms of this issue.)

I didn't pay especially close attention to the ones that worked. I can send out a request for more details, but they aren't phones I have access to directly.

gnprice commented 5 years ago

Fascinating, thanks @cognusion ! That suggests that this issue interacts with something that varies between OS versions... both between iOS versions and between Android versions, which means two different changes (something in iOS changed, and something in Android changed or was introduced by an Android OEM.)

Especially interesting is that it seems to differ between minor versions of iOS 12, and moreover with a single device model (iPhone 6).

One thing I wonder is if there's some other variable on the devices that is affecting the issue. Perhaps a setting? ... I don't see any relevant-looking setting in Android 9 on my Pixel 2 XL. My iPhone is out of battery, so can't immediately check there; charging now.

Also very helpful, if you can, would be to get your hands on one of the devices where the issue is not happening, and attempt to repro there yourself. I wonder if there's some subtle difference between what you're doing and what people who aren't seeing the issue (including both me and @jainkuniya so far) are doing, something we're all just not successfully communicating in text. So if you can try the exact same recipe on two devices, one after the other, and it repros on one and not the other, that will be very helpful confirmation that it's not that... and conversely, if it does repro on someone's device who hadn't been seeing it, then that will be an excellent lead.

gnprice commented 5 years ago

One thing I wonder is if there's some other variable on the devices that is affecting the issue. Perhaps a setting? ... I don't see any relevant-looking setting in Android 9 on my Pixel 2 XL. My iPhone is out of battery, so can't immediately check there; charging now.

Just looked at the camera settings in iOS 12.4.1 on my iPhone 7, and I don't see anything that looks like it could be relevant there either. :man_shrugging:

cognusion commented 5 years ago

A Samsung Galaxy S9, running Android 9, in my hands with the same process yields properly-portraited uploads via Zulip Mobile.

Additionally, I used the in-Zulip photo option on both that S9 and a MotoZ3, the S9 was properly-portraited, the Z3 was improperly-landscaped (which it does from the gallery as well).

gnprice commented 5 years ago

@cognusion Cool. Thanks for pinning that down!

gnprice commented 5 years ago

OK, another report today from @timabbott in chat... and I think we have a diagnosis!

Tim ran into the issue on a Samsung Galaxy S9+ running Android 9. His encounter with it was in the chat.zulip.org realm where I could see it directly, so that helped me investigate.

It turns out that if I just click through to open the image URL itself in my browser... it shows up correctly oriented! So the server has the image just fine, but it shows up wrong when part of a webpage, and similarly when part of the message list in the mobile app.

Looking closer, if I download the photo to my desktop and run file, it reports:

JPEG image data, Exif standard: ..., orientation=upper-right, ...

I believe that means the pixel at coordinates (0, 0) is supposed to go in the upper-right corner (rather than the usual upper-left) -- and the issue is that <img> in HTML doesn't respect that EXIF orientation metadata. That would completely explain what we're seeing.

When I take photos with my Pixel 2 XL running Android 10, in any orientation, the same EXIF metadata always comes out as the default orientation=upper-left. I.e., the device is handling rotation by rearranging the actual pixels, to avoid relying on orientation metadata.

Given that diagnosis, I think the proper place to fix this is on the server and/or the webapp: the same files will produce the same result if uploaded from a desktop, without involving the mobile app at all. (If there ends up being a piece the web frontend takes care of at display time, we'll then do something similar in the mobile app.)

This thread is long enough that rather than move it between repos, I'll go make a fresh thread in zulip/zulip .

gnprice commented 5 years ago

Oho, and this is already zulip/zulip#8177. So I'll just bring the new information over there.

gnprice commented 5 years ago

Given what we've now learned, this is a duplicate of zulip/zulip#8177 . I'm going to close it to consolidate discussion there; I'll edit the description to point there, too.

gnprice commented 5 years ago

(Thanks again @cognusion for the many observations which helped us understand this better, and @jainkuniya for the effort to reproduce!)

gnprice commented 4 years ago

Reopening this, to serve as a sort of mirror of the status of the main issue zulip/zulip#8177.

That issue naturally doesn't show up when searching this repo's issue tracker, so it's confusing to have the issue with this title show up as closed when the issue is still unfixed.

Discussion should still be concentrated at zulip/zulip#8177.

cognusion commented 4 years ago

I noticed that in a recent mobile release, this has been resolved, and mobile uploads are appearing in the correct orientation on the mobile client! :smiley: Mobile uploads viewed in the desktop client, however, are still unoriented. :cry: Glad to see there's progress! :+1:

gnprice commented 4 years ago

This is now getting fixed in browsers! :confetti_ball: Details here: https://github.com/zulip/zulip/issues/8177#issuecomment-621468621

Thanks to @cognusion for noticing the change (and the detailed investigation over on zulip/zulip#8177.)

I've filed zulip/zulip-desktop#946 for the desktop client to ship the update. Webapp users should see the problem resolved as their browser updates -- the latest Chrome and Safari should already have the fix, and in Firefox it's coming soon. Android users will see the problem resolve with the latest Chrome update, and I believe iOS users should see the problem resolve with iOS 13, possibly earlier.

timabbott commented 4 years ago

Should we close this now that the desktop app is on Electron 9 and thus zulip/zulip-desktop#946 is resolved?

chrisbobbe commented 4 years ago

Thanks for the follow-up, Tim! That looks correct to me; closing now.