Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.57k stars 2.91k forks source link

[HOLD for PR #18997] Chat - Infinite loading after opening attached image a few times #24067

Open lanitochka17 opened 1 year ago

lanitochka17 commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open the app
  2. Open any chat
  3. Tap the "+" button and select "Add attachment" > "Choose from gallery"
  4. Select any image and tap "Send"
  5. Open the image and close it a few times

Expected Result:

The image preview is shown every time

Actual Result:

Infinite loading after opening the image preview a few times. The same behavior when opening images from old chats

Workaround:

Unknown

Platforms:

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

Version Number: 1.3.49.0

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Notes/Photos/Videos: Any additional supporting documentation

https://github.com/Expensify/App/assets/78819774/0fe353c5-d2d0-4577-8a92-a5fce6b361bd

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

honnamkuan commented 1 year ago

Proposal

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

When image attachment is opened several times in Native apps, sometimes the loading icon is shown forever and the image preview does not load.

What is the root cause of that problem?

In ImageView (index.native.js), we have callback function logics to set isLoading: true in onLoadStart callback; and isLoading: false in onLoad callback;

see: https://github.com/Expensify/App/blob/2f750ad9fad7be1b1e4095a778385ea5a2f06f3b/src/components/ImageView/index.native.js#L225-L226

That works well when it is the first time the image is being opened, onLoadStart get called first when loading start, and onLoad get called later when loading ends.

However, when an image is being opened more than once, it is already cached, so technically the image does not need to be loaded anymore, onLoadStart and onLoad callbacks actually fires at the same time in these cases. Sometimes onLoadStart fires first, and we have no problem. Other times, onLoad fires first, followed by onLoadStart, in this scenario, isLoading state is set to false and then true, thus the loading icon is shown forever instead of image preview.

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

We actually do not need to configure onLoadStart callback, as its purpose is to resetImageZoom whenever the source image URL changes. That is already handled via componentDidUpdate component lifecycle function, which is already calling resetImageZoom whenever the URL changes.

https://github.com/Expensify/App/blob/2f750ad9fad7be1b1e4095a778385ea5a2f06f3b/src/components/ImageView/index.native.js#L63-L68

To resolve the issue, we should unset onLoadStart by removing this line https://github.com/Expensify/App/blob/2f750ad9fad7be1b1e4095a778385ea5a2f06f3b/src/components/ImageView/index.native.js#L225

What alternative solutions did you explore? (Optional)

If the indeterministic firing sequence of onLoadStart and onLoad when image does not requires loading (when already cached) is considered as a bug in upstream library react-native-fast-image, then we can also choose to submit a PR fix upstream.

gadhiyamanan commented 1 year ago

might be same root cause https://github.com/Expensify/App/issues/22920

garrettmknight commented 1 year ago

@gadhiyamanan agreed, I think this looks like the same root cause. Let's put this on hold and leave this open until this PR is deployed. I'll retest and see if that fixed it.

garrettmknight commented 1 year ago

Still holding

garrettmknight commented 1 year ago

Still holding

garrettmknight commented 1 year ago

Still holding

garrettmknight commented 1 year ago

Still holding

garrettmknight commented 1 year ago

Still holding

garrettmknight commented 1 year ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 1 year ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 1 year ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 1 year ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 1 year ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 1 year ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 11 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 11 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 11 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 11 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 10 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 10 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 10 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 9 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 9 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 9 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 8 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 8 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 8 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 8 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 8 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 7 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 7 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 7 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 6 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 6 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 6 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 6 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 5 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 5 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 5 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 4 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 4 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 4 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 3 months ago

Still holding

garrettmknight commented 3 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 3 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 2 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 2 months ago

Still holding on https://github.com/Expensify/App/pull/18997

garrettmknight commented 1 month ago

Still holding on https://github.com/Expensify/App/pull/18997