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: Blurred images in attachment view on mobile devices #6442

Merged
merged 10 commits into from
Nov 26, 2021

Conversation

aswin-s
Copy link
Contributor

@aswin-s aswin-s commented Nov 23, 2021

Details

This PR fixes issue an issue with image attachment view, where the images were blurred out once loaded.

Fixed Issues

$ #5193

Tests

  1. Navigate to a conversation
  2. Send an image
  3. Tap on the image and zoom
  4. Verify that the image shown is sharp and fits to screen width.

QA Steps

  1. Navigate to a conversation
  2. Send an image
  3. Tap on the image and zoom
  4. Verify that the image shown is sharp and fits to screen.
  5. Repeat above steps with images of different dimensions, especially large images like this

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Issue is present only on mobile devices.

iOS

image

Simulator.Screen.Recording.-.iPhone.12.-.2021-11-24.at.02.21.49.mp4

Android

Screenshot_1637700815

Screen.Recording.2021-11-24.at.2.25.47.AM.mp4

@aswin-s aswin-s requested a review from a team as a code owner November 23, 2021 20:58
@MelvinBot MelvinBot requested review from iwiznia and removed request for a team November 23, 2021 20:58
@@ -102,21 +144,14 @@ class ImageView extends PureComponent {
this.imageZoomScale = scale;
}}
>
<ImageWithSizeCalculation
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm I wonder if we should move all this logic to this component instead... what's the value of keeping both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ImageWithSizeCalculation component is used in Web & Desktop platforms as well and current implementation works just fine for those. Keeping the logic contained in ImageView native implementation, we basically keep the unnecessary dependencies out of web bundle & avoid webpack errors. If you still prefer to keep it in ImageSizeWithCalculation then it needs to have a native implementation which uses FastImage & RNImageSize.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh ok ok, no, this is good.

@aswin-s aswin-s requested a review from iwiznia November 24, 2021 20:23
@iwiznia
Copy link
Contributor

iwiznia commented Nov 25, 2021

Argh damn, sorry you got conflicts.

@aswin-s
Copy link
Contributor Author

aswin-s commented Nov 25, 2021

@iwiznia Resolved conflicts

}

componentWillUnmount() {
if (!this.state.interactionPromise) { return; }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think our style guide says to not do this (ie: we should have return in a new line and the close bracket in another one.
Having said that, you can change this to: this.state.interactionPromise && this.state.interactionPromise.cancel()

Copy link
Contributor Author

@aswin-s aswin-s Nov 26, 2021

Choose a reason for hiding this comment

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

Oh that actually throws Expected an assignment or function call and instead saw an expression.eslintno-unused-expressions lint error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to return in new line.

@aswin-s aswin-s requested a review from iwiznia November 26, 2021 14:33
@iwiznia
Copy link
Contributor

iwiznia commented Nov 26, 2021

Just realized I had to approve you as contributor for the workflow to run. Please ping me again to merge it when the workflow runs successfully.

@aswin-s
Copy link
Contributor Author

aswin-s commented Nov 26, 2021

@iwiznia All checks passed.

@iwiznia
Copy link
Contributor

iwiznia commented Nov 26, 2021

Awesome, can you clarify in the QA steps to do the tests with images of various sizes, especially with big image sizes?

@iwiznia iwiznia merged commit 85d9a21 into Expensify:main Nov 26, 2021
@OSBotify
Copy link
Contributor

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

@aswin-s aswin-s deleted the aswin-s/issue_5193 branch November 26, 2021 16:11
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @iwiznia in version: 1.1.16-11 🚀

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

@roryabraham
Copy link
Contributor

As stated over here, I'm going to revert this PR because it caused a regression.

@roryabraham
Copy link
Contributor

roryabraham commented Dec 6, 2021

Darn, couldn't be reverted automatically 😭

@OSBotify
Copy link
Contributor

OSBotify commented Dec 6, 2021

🚀 Deployed to production by @roryabraham in version: 1.1.17-7 🚀

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

@s77rt
Copy link
Contributor

s77rt commented Mar 3, 2023

This PR is party responsible for a regression here #15288 The react-native-fast-image lib is bugged.

Comment on lines +49 to +50
// Wait till animations are over to prevent stutter in navigation animation
this.state.interactionPromise = InteractionManager.runAfterInteractions(() => this.calculateImageSize());
Copy link
Contributor

Choose a reason for hiding this comment

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

@aswin-s Do you recall the production steps for the animation bug here? We are looking to remove InteractionManager.runAfterInteractions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow this was over 2 years ago. If I remember correctly trying to calculate image size while animating the modal was causing frozen frames on android device. But this component has gone through multiple refactors after this change and even react-native-fast-image was forked to improve load performance. So this optimisation might not be required anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

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.

5 participants