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

[HOLD for payment 2023-10-09] [$500] Chat - Loader is shown on top of image even after image is loaded in attachment carousel #26046

Closed
1 of 6 tasks
lanitochka17 opened this issue Aug 28, 2023 · 49 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 28, 2023

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


Action Performed:

  1. Open a report
  2. Send 3-4 images/pdf's
  3. Scroll through carousel multiple times

Expected Result:

The loader should not appear on top of the image if the image is already loaded

Actual Result:

The loader appears on top of the image even if the image is already loaded

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.57-5

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

WhatsApp.Video.2023-08-19.at.16.46.18.mp4
Record_2023-08-27-22-02-15_4f9154176b47c00da84e32064abf1c48.mp4

Expensify/Expensify Issue URL:

Issue reported by: @Krishna2323

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692443921240289

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e48d51a0940adaac
  • Upwork Job ID: 1699172582322225152
  • Last Price Increase: 2023-09-12
  • Automatic offers:
    • Krishna2323 | Contributor | 26743909
    • krishna2323 | Reporter | 26743910
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Aug 28, 2023

Proposal

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

Chat - Loader is shown on top of image even after image is loaded in attachment carousel

What is the root cause of that problem?

from this PR https://github.com/Expensify/App/pull/20798/files#diff-d0e9c4b27eeb3cf558959584e3c3ea569b9a70c4fa1334846ac028a504cf035d introduced ImageTransformer so every time isActive image will transform

onLoadStart={() => setIsImageLoading(true)}
onLoadEnd={() => setIsImageLoading(false)}
so that flickering will occur every time load an image and transform

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

we should check image is already Transformed or not. This AttachmentCarouselPage is loaded from Flatlist so we need to declare one more state

    const [isImageTransformered, setIsImageTransformered] = useState(false);

and here

we need declare setIsImageTransformered(true);
and on onLoadEnd as well.
and
onLoadStart={() => setIsImageLoading(true)}

add onLoadEnd={() => setIsImageTransformered(true)}

the loader should show if the image is not Transforming only isActive && !isImageTransformered

Result

Screen.Recording.2023-09-15.at.6.51.36.AM.mov

@Krishna2323
Copy link
Contributor

Krishna2323 commented Aug 28, 2023

Proposal

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

Chat - Loader is shown on top of image even after image is loaded in attachment carousel

What is the root cause of that problem?

Our loader is configured to show as soon as the loading process began, without distinguishing between images loaded from the cache and those fetched from the internet. This meant that even if an image was instantly available in the cache and displayed immediately, our loader logic would still interpret this as a loading sequence. As a result, the isLoading state would momentarily set to true, only to revert back to false instantly, causing the loading indicator to flash or flicker briefly.

I already fixed similar issue few weeks ago: PR

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

To address the flickering loader issue, we should introduce a slight delay before showing the loader, allowing cached images to display without triggering the loading indicator. Simultaneously, we need to enhance our mechanism for tracking image load status, ensuring that once an image is loaded, its status is remembered, preventing unnecessary loader displays for cached images. Synchronizing the fallback display with the image's actual load status will further mitigate the flash of the loader. Lastly, optimizing the caching of image dimensions will expedite image rendering, contributing to a smoother user experience.

Imports:

  • Imported useRef and _ from 'underscore' in the new code.

State Variables:

  • Added a new state variable isImageCached which is used to determine if the image is being loaded from the cache or the internet.
  • Initialized isImageLoading state to false instead of true.
  • Initialized showFallback state to true instead of isImageLoading.
    const [isImageLoading, setIsImageLoading] = useState(false);
    const [showFallback, setShowFallback] = useState(true);
    const [isImageCached, setIsImageCached] = useState(true);

Refs:

  • Introduced a new ref isLoadedRef which seems to act as a flag to track if the image has been loaded at least once.

const isLoadedRef = useRef(null);

Effects:

  • In the new code, there's an added effect that checks if the image is being loaded from cache or the internet. It introduces a delay using _.delay() from the underscore library to decide whether to update isImageCached.
    useEffect(() => {
        if (isLoadedRef.current || !isImageLoading) {
            return;
        }
        const timeout = _.delay(() => {
            if (!isImageLoading || isLoadedRef.current) {
                return;
            }
            setIsImageCached(false);
        }, 200);
        return () => clearTimeout(timeout);
    }, [isImageLoading]);

Image Component:

  • The callback for the onLoadStart event of the inside the ImageTransformer was removed in the new code.
  • The onLoadStart and onLoadEnd events of the inside the ImageWrapper were modified. The new onLoadStart checks the isLoadedRef and isImageLoading before setting isImageLoading to true. The onLoadEnd now sets both isImageLoading to false and isLoadedRef.current to true.
     onLoadStart={() => {
        if (isLoadedRef.current || isImageLoading) {
              return;
        }
        setIsImageLoading(true);
      }}

ActivityIndicator:

  • The condition to show the ActivityIndicator is now (isActive && isImageLoading && !isImageCached). This means the loading spinner will only be shown if the page is active, the image is still loading, and the image is not cached.
    {isActive && isImageLoading && !isImageCached && (
        <ActivityIndicator
            size="large"
            style={StyleSheet.absoluteFill}
        />
    )}

Result

fix_demo.mp4

@melvin-bot melvin-bot bot added the Overdue label Aug 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 2023

@sakluger Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@sakluger

This comment was marked as resolved.

@melvin-bot melvin-bot bot removed the Overdue label Aug 31, 2023
@sakluger

This comment was marked as outdated.

@sakluger sakluger reopened this Aug 31, 2023
@Krishna2323
Copy link
Contributor

@sakluger, that's what I was thinking 😂

@sakluger
Copy link
Contributor

I'm sure we've fixed this before. Here's one issue where we fixed an issue of the carousel loading every image multiple times: #15922. @kidroca @thesahindia you worked on that issue so I'm hoping you're familiar - is this a regression of that one?

@melvin-bot melvin-bot bot added the Overdue label Sep 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 2023

@sakluger Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@sakluger
Copy link
Contributor

sakluger commented Sep 5, 2023

Posted in the original Slack thread again.

@melvin-bot melvin-bot bot removed the Overdue label Sep 5, 2023
@sakluger
Copy link
Contributor

sakluger commented Sep 5, 2023

@thesahindia confirmed that we fixed this and it's a regression. Adding external label, I'd like to first see if we can track down the regression, because the person who caused it should ideally fix it.

@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Sep 5, 2023
@melvin-bot melvin-bot bot changed the title Chat - Loader is shown on top of image even after image is loaded in attachment carousel [$500] Chat - Loader is shown on top of image even after image is loaded in attachment carousel Sep 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 5, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01e48d51a0940adaac

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 5, 2023

Current assignee @sakluger is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Sep 5, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

@sakluger @parasharrajat this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@melvin-bot melvin-bot bot added the Overdue label Sep 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

📣 @Krishna2323 🎉 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 📖

@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

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

Offer link
Upwork job

Krishna2323 added a commit to Krishna2323/App that referenced this issue Sep 19, 2023
Krishna2323 added a commit to Krishna2323/App that referenced this issue Sep 19, 2023
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 19, 2023
@Krishna2323
Copy link
Contributor

@eVoloshchak, PR is ready, friendly reminder.

@melvin-bot
Copy link

melvin-bot bot commented Sep 26, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @Krishna2323 got assigned: 2023-09-19 01:55:00 Z
  • when the PR got merged: 2023-09-26 02:45:40 UTC
  • days elapsed: 5

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 2, 2023
@melvin-bot melvin-bot bot changed the title [$500] Chat - Loader is shown on top of image even after image is loaded in attachment carousel [HOLD for payment 2023-10-09] [$500] Chat - Loader is shown on top of image even after image is loaded in attachment carousel Oct 2, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.75-12 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-09. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@eVoloshchak] The PR that introduced the bug has been identified. Link to the PR:
  • [@eVoloshchak] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@eVoloshchak] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@eVoloshchak] Determine if we should create a regression test for this bug.
  • [@eVoloshchak] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@sakluger] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels Oct 9, 2023
@Krishna2323
Copy link
Contributor

@sakluger, bump for payments here, just noting this issue was created on Aug 28.

@eVoloshchak
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: I'm unable to pinpoint the exact PR that caused this, the root cause for this was present in the initial implementation
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: N/A
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: I don't think an additional discussion is needed, the bug is specific to this particular component, there is no universal approach/checklist item we could implement

@eVoloshchak
Copy link
Contributor

Regression Test Proposal

  1. Open any chat
  2. Send 3-4 images
  3. Scroll through the carousel multiple times
  4. Verify that the loader doesn't briefly appear on top of the image if the image is already loaded

Do we agree 👍 or 👎

@sakluger
Copy link
Contributor

@Krishna2323 thanks for the reminder on the issue creation date. I updated the offers accordingly.

@eVoloshchak does not require payment (Eligible for Manual Requests)
@Krishna2323 requires payment offer (Contributor)
@Krishna2323 requires payment offer (Contributor)

Summarizing payouts for this issue:

Reporter: @Krishna2323 $250 (paid via Upwork)
Contributor: @Krishna2323 $1000 (paid via Upwork)
Contributor+: @eVoloshchak $1000 (payable via Manual Request)

Above payments include efficiency bonus 🎉
Upwork job: https://www.upwork.com/jobs/~01e48d51a0940adaac

@sakluger
Copy link
Contributor

@eVoloshchak let me know once you've sent the manual request, I'll close the issue at that point. Thanks!

@eVoloshchak
Copy link
Contributor

@sakluger, request has been sent, thank you!

@JmillsExpensify
Copy link

$1,000 payment approved for @eVoloshchak based on BZ summary.

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

No branches or pull requests

8 participants