Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : Android - Picture looks smaller in Preview page #7660

Merged
merged 23 commits into from
Mar 3, 2022

Conversation

ahmdshrif
Copy link
Contributor

@ahmdshrif ahmdshrif commented Feb 9, 2022

Details

Fixed Issues

$ #7591

Tests

  • Verify that no errors appear in the JS console

QA Steps

1- Launch the app
2- Log in with any account
3- Tap on any user
4- Tap on plus button and add attachment
5- Tap on Select from Gallery
6- Attach any picture from Gallery
7- Tap Send
8- Tap on attachment again

  • Verify that no errors appear in the JS console

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Screen Shot 2022-02-09 at 10 48 26 PM

Mobile Web

Screen Shot 2022-02-09 at 11 09 42 PM

Desktop

iOS

Screen Shot 2022-02-09 at 10 01 25 PM

Android

Screen Shot 2022-02-09 at 9 35 03 PM

@ahmdshrif ahmdshrif marked this pull request as ready for review February 9, 2022 20:10
@ahmdshrif ahmdshrif requested a review from a team as a code owner February 9, 2022 20:10
@MelvinBot MelvinBot removed the request for review from a team February 9, 2022 20:10
@AndrewGable
Copy link
Contributor

Can we test on all platforms? Thanks!

@ahmdshrif
Copy link
Contributor Author

I think the issue was reported on android only and I do fix it for native.
I catch this issue on the web also. do I need to search for a new fix since the web has another way to handle image preview ? or can I report it as a new issue?

Screen Shot 2022-02-09 at 10 30 05 PM

@rushatgabhane
Copy link
Member

@ahmdshrif let's try to fix it for web too

@ahmdshrif
Copy link
Contributor Author

On the web, you can just click and this will do the zoom we expect
Screen Shot 2022-02-09 at 10 32 43 PM

@AndrewGable
Copy link
Contributor

If the bug doesn't happen on main, then this PR broke it. All issues need to be fixed across all platforms.

@rushatgabhane
Copy link
Member

rushatgabhane commented Feb 9, 2022

the web and desktop bug is on main too

@AndrewGable
Copy link
Contributor

Makes sense, then let's fix across all platforms 👍

@ahmdshrif
Copy link
Contributor Author

ok, working on a web and desktop fix.

@ahmdshrif
Copy link
Contributor Author

I add zoom to be true as the default value on the web.
and it does what we expect.

Screen.Recording.2022-02-09.at.10.45.18.PM.mov

@rushatgabhane
Copy link
Member

As long as it doesn't cause a regression, that's fine.

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmdshrif all images on web are zoomed in by default. Let's fix that

@ahmdshrif
Copy link
Contributor Author

@ahmdshrif all images on web are zoomed in by default. Let's fix that

@rushatgabhane I think that is what we expect. the small image does not fill the screen so we zoom it by default to take the screen width.

or what do you mean

@rushatgabhane
Copy link
Member

rushatgabhane commented Feb 9, 2022

@ahmdshrif an image that isn't small is zoomed by default.

Screencast.from.10-02-22.12-44-29.AM.+03.1.mp4

@ahmdshrif
Copy link
Contributor Author

ok get it will fix that , thanks

@ahmdshrif
Copy link
Contributor Author

I get this error when trying to run on the desktop is this my local issue or is this issue on the main.

[Renderer] [HPM] Error occurred while trying to proxy request /api?command=Log from localhost:8080 to http://[::1]:9000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
[Renderer] [HPM] Error occurred while trying to proxy request /api?command=Log from localhost:8080 to http://[::1]:9000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

@rushatgabhane
Copy link
Member

@ahmdshrif desktop is working fine for me.

@ahmdshrif
Copy link
Contributor Author

ahmdshrif commented Feb 9, 2022

it shoud be fix now @rushatgabhane
the web zooming

@@ -22,7 +22,7 @@ class ImageView extends PureComponent {
this.state = {
containerHeight: 0,
containerWidth: 0,
isZoomed: false,
isZoomed: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmdshrif can we go with an alternative approach because it feels like a workaround, and it's buggy. Let's keep isZoomed be false by default.

It's still buggy for normal images. What do you think of using imgTop, imgLeft, etc instead.

screencast-from-10-02-22-05-12-43-pm-03_GIc5JsAV.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it must not get zooming if it's small. Let me try to test with different image sizes. on my side.
I think imgTop, imgLeft, is more related to position when you move the image. but let me check this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane can you share with me the image that have the issue because for me I try many image sizes and still work fine with me

Screen.Recording.2022-02-11.at.1.49.35.AM.mov

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you go RDT_20220131_1353072297764153181649913

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cute puppy 😍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane ok thanks, I fix t it now

Screen.Recording.2022-02-11.at.2.09.24.AM.mov

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cute puppy 😍

ikrr 😍

@rushatgabhane ok thanks, I fix t it now

Fantastic!

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmdshrif two points for large images.

  1. The image is zoomed in only for the first time it's opened. (subsequent opens aren't zoomed but they have the flicker problem below)
  2. The image flickers from zoomed in to zoomed out state which is undesireable.

Also, small images are zoomed in by default, so we can't zoom them in further.

Let me know what you think

Screencast.from.11-02-22.03-27-34.AM.+03.mp4

@ahmdshrif
Copy link
Contributor Author

ok, thanks for your feedback I will take some time thinking about a more stable way for the web.

@ahmdshrif
Copy link
Contributor Author

@rushatgabhane it's now stable and we can zoom the small image also.

preview :

Screen.Recording.2022-02-13.at.4.32.44.PM.mov

Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmdshrif sorry, but requesting a really minor change.

Could you please add JSdoc for all the functions, thanks!

ahmdshrif and others added 2 commits March 2, 2022 10:53
Co-authored-by: Andrew Gable <andrewgable@gmail.com>
src/components/ImageView/index.js Outdated Show resolved Hide resolved
src/components/ImageView/index.js Outdated Show resolved Hide resolved
src/components/ImageView/index.js Outdated Show resolved Hide resolved
src/components/ImageView/index.js Outdated Show resolved Hide resolved
Copy link
Member

@rushatgabhane rushatgabhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndrewGable all yours! LGTM

@AndrewGable AndrewGable merged commit ea691f0 into Expensify:main Mar 3, 2022
@OSBotify
Copy link
Contributor

OSBotify commented Mar 3, 2022

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @AndrewGable in version: 1.1.42-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@kbecciv
Copy link

kbecciv commented Mar 14, 2022

@ahmdshrif @AndrewGable @rushatgabhane PR is failing on 1.1.42.3 build

Screen_Recording_20220311-083833_New.Expensify.mp4

@ahmdshrif
Copy link
Contributor Author

ahmdshrif commented Mar 14, 2022

@kbecciv which platform it fails on it?
and can you please share the image that fails?

@kbecciv
Copy link

kbecciv commented Mar 14, 2022

@ahmdshrif It fails on Andriod app.
3AFFEA14-2707-4DC5-8FD6-2CF3EFD27ABE jpeg

@ahmdshrif
Copy link
Contributor Author

ook, we can repro this issue with very small images only. #7591 (comment)
and this is one of the other edge cases we can't repro during the test. and need to be handled also.

@rushatgabhane
Copy link
Member

@ahmdshrif wait what, I don't understand why this particular image isn't working while these are - #7591 (comment).

The image width and height is correct too

imageWidth = Math.round(this.props.windowWidth);
imageHeight = Math.round(imageWidth * aspectRatio);

@ahmdshrif
Copy link
Contributor Author

ahmdshrif commented Mar 15, 2022

I am still debugging this. I just mention we do not repro this because this edge case wasn't mentioned.

for now, I just note this image has a large size, and android was crashed with this image. and we have a workaround to avoid this crash.

// Resize the image to max dimensions possible on the Native platforms to prevent crashes on Android. To keep the same behavior, apply to IOS as well.
            const maxDimensionsScale = 11;
            imageHeight = Math.min(imageHeight, (this.props.windowHeight * maxDimensionsScale));

@rushatgabhane
Copy link
Member

rushatgabhane commented Mar 15, 2022

Cool.
Note: large images like this one - #7660 (comment) work

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @chiragsalian in version: 1.1.42-6 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@ahmdshrif
Copy link
Contributor Author

@rushatgabhane yes this case is so weird

@ahmdshrif
Copy link
Contributor Author

ahmdshrif commented Mar 17, 2022

the update I have for now is this something related to android and how he resize the image
because the same code works fine on ios.

android gets stuck with an image with this size(and aspect ratio) only but still works fine with other sizes.

I think the solution will be to change most of the code on the calculateImageSize to make sure it's not going to this edge case for android.
is this something we should do here or can move it to a new issue? @AndrewGable @rushatgabhane

Screen Shot 2022-03-17 at 11 59 38 PM

@Christinadobrzyn
Copy link
Contributor

@AndrewGable and @rushatgabhane - sorry to also ping you but we're at the 7 day payment timeframe. Is this new issue a regression that needs to be fixed before paying/closing this job?

@rushatgabhane
Copy link
Member

rushatgabhane commented Mar 24, 2022

@Christinadobrzyn this issue isn't completely fixed, I've asked @ahmdshrif to fix it here - #7591 (comment)

We'll create a follow up PR, after which the payment should be done. I hope this answers your question

@ahmdshrif ahmdshrif mentioned this pull request Apr 1, 2022
53 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants