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

[$500] Android – Attachment – App flickering when uploading a long image to a conversation #34998

Closed
1 of 6 tasks
lanitochka17 opened this issue Jan 23, 2024 · 18 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 23, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.30-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Open New Expensify app
  2. Log in with the account
  3. Open any chat
  4. On a conversation, click on the + button in the compose box
  5. Upload long image to a conversation

Expected Result:

Preview of the image is displayed before uploading to the conversation

Actual Result:

App flickering when uploading a long image to a conversation in preview. Flashes on first boot

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6352453_1706038657902.App_flickering_when_uploading_a_long_image.mp4

Bug6352453_1706038657893!bigggg

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011d877180b69b96f5
  • Upwork Job ID: 1749885428346445824
  • Last Price Increase: 2024-01-30
  • Automatic offers:
    • jjcoffee | Reviewer | 28132224
    • ZhenjaHorbach | Contributor | 28132225
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 23, 2024
Copy link

melvin-bot bot commented Jan 23, 2024

Job added to Upwork: https://www.upwork.com/jobs/~011d877180b69b96f5

@melvin-bot melvin-bot bot changed the title Android – Attachment – App flickering when uploading a long image to a conversation [$500] Android – Attachment – App flickering when uploading a long image to a conversation Jan 23, 2024
Copy link

melvin-bot bot commented Jan 23, 2024

Triggered auto assignment to @greg-schroeder (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 23, 2024
Copy link

melvin-bot bot commented Jan 23, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (External)

@ZhenjaHorbach
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Android – Attachment – App flickering when uploading a long image to a conversation

What is the root cause of that problem?

The main problem with the issue is that when we load a long photo we call onLoad a few times ( But according to the documentation, onLoad should only call once, which means the image is completely loaded )

onLoad={(e) => {
const width = (e.nativeEvent?.width || 0) * PixelRatio.get();
const height = (e.nativeEvent?.height || 0) * PixelRatio.get();
setImageDimensions({...imageDimensions, lightboxSize: {width, height}});
}}

What changes do you think we should make in order to solve the problem?

To fix this issue we can update the code and add new condition which will prevent unnecessary onLoad calls. For this we can use isLightboxLoaded

                                    onLoad={(e) => {
                                        if (isLightboxLoaded) {
                                            return;
                                        }

                                        const width = (e.nativeEvent?.width || 0) * PixelRatio.get();
                                        const height = (e.nativeEvent?.height || 0) * PixelRatio.get();
                                        setImageDimensions({...imageDimensions, lightboxSize: {width, height}});
                                    }}

What alternative solutions did you explore? (Optional)

NA

@jjcoffee
Copy link
Contributor

Reviewing tomorrow!

@melvin-bot melvin-bot bot added the Overdue label Jan 29, 2024
@jjcoffee
Copy link
Contributor

@ZhenjaHorbach Thanks for the proposal! The RCA feels a bit underdeveloped; I'm curious why onLoad is being called multiple times if it's only supposed to be called once. I also wonder if this is device specific?

@lanitochka17 Could you update/add which platforms this affects?

@melvin-bot melvin-bot bot removed the Overdue label Jan 29, 2024
@ZhenjaHorbach
Copy link
Contributor

@ZhenjaHorbach Thanks for the proposal! The RCA feels a bit underdeveloped; I'm curious why onLoad is being called multiple times if it's only supposed to be called once. I also wonder if this is device specific?

@lanitochka17 Could you update/add which platforms this affects?

This problem is specific to Android only
In fact, for all native components because Lightbox is only used for native components, but on iOS I don’t notice this

And the problem is related to rerendering
Since we use several useStates
After changing the state, onLoad is triggered

But if on IOS we always have a static size value
On Android it looks like some kind of native bug and we get different values

But my fix is still valid
Judging by the size of the image on the screen
The first value that we save in the state is more correct

@lanitochka17
Copy link
Author

The issue is only reproducible on Android

Copy link

melvin-bot bot commented Jan 30, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@jjcoffee
Copy link
Contributor

Thanks for the extra detail! Happy to go with @ZhenjaHorbach's proposal here. The RCA seems correct that we're simply calling onLoad multiple times on Android (for some reason with different sizes), and the solution makes sense for that.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Jan 31, 2024

Triggered auto assignment to @Julesssss, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 31, 2024
Copy link

melvin-bot bot commented Jan 31, 2024

📣 @jjcoffee 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Jan 31, 2024

📣 @ZhenjaHorbach 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@ZhenjaHorbach
Copy link
Contributor

📣 @ZhenjaHorbach 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

PR will be ready today or tomorrow

@ZhenjaHorbach
Copy link
Contributor

ZhenjaHorbach commented Jan 31, 2024

@jjcoffee

const updateContentSize = useCallback(
({nativeEvent: {width, height}}: ImageOnLoadEvent) => {
if (contentSize !== undefined) {
return;
}
setContentSize({width: width * PixelRatio.get(), height: height * PixelRatio.get()});
},
[contentSize, setContentSize],
);

It seems this problem is no longer relevant after refactoring the code into this PR
#33756

In fact, the fix is already used here

@jjcoffee
Copy link
Contributor

jjcoffee commented Feb 1, 2024

@ZhenjaHorbach Thanks for flagging! Did you verify that the issue is fixed?

@ZhenjaHorbach
Copy link
Contributor

I couldn't reproduce it on the last main )

@greg-schroeder
Copy link
Contributor

Great! Closing this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

5 participants