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 18997] [$1000] Android- infinite loading on open profile pic preview second time #22920

Closed
1 of 6 tasks
kbecciv opened this issue Jul 14, 2023 · 15 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Monthly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Jul 14, 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. Go to any chat
  2. Click on any user to see details
  3. Click on profile pic to see preview
  4. Click on back button
  5. Again click on profile pic to see preview

Expected Result:

Should show profile pic preview

Actual Result:

Infinite loading on open profile pic

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.39-11
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
Notes/Photos/Videos: Any additional supporting documentation

Screen_Recording_20230714_164616_New.Expensify.mp4
Screen_Recording_20230714_170233_Expensify.Chat.1.mp4

Expensify/Expensify Issue URL:
Issue reported by: @gadhiyamanan
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1689333392843659

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01d82661194c0b255b
  • Upwork Job ID: 1681049828862857216
  • Last Price Increase: 2023-07-17
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 14, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 14, 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

@jfquevedol2198
Copy link
Contributor

jfquevedol2198 commented Jul 14, 2023

Proposal

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

Android- infinite loading on open profile pic preview second time

What is the root cause of that problem?

On second loading of ImageView, isLoading is true although image is already loaded in ImageView component.
Problem is with Image component, Image component is using react-native-fast-image, it supports image caching like browser.

On first loading, Image component lifecycle is onLoadStart => onLoad => onLoadEnd.
FYI, we are not using onLoadEnd callback.

<Image
style={[
styles.w100,
styles.h100,
this.props.style,
// Hide image while loading so ImageZoom can get the image
// size before presenting - preventing visual glitches or shift
// due to ImageZoom
shouldShowLoadingIndicator ? styles.opacity0 : styles.opacity1,
]}
source={{uri: this.props.url}}
isAuthTokenRequired={this.props.isAuthTokenRequired}
resizeMode={Image.resizeMode.contain}
onLoadStart={this.imageLoadingStart}
onLoad={this.configureImageZoom}
/>

isLoading is true on component loading, and onLoadStart is also updating isLoading to true

imageLoadingStart() {
if (this.state.isLoading) {
return;
}
this.resetImageZoom();
this.setState({imageHeight: 0, imageWidth: 0, isLoading: true});
}

When onLoad is invoked, isLoading becomes true currently.

configureImageZoom({nativeEvent}) {
let imageWidth = nativeEvent.width;
let imageHeight = nativeEvent.height;
const containerWidth = Math.round(this.props.windowWidth);
const containerHeight = Math.round(this.state.containerHeight ? this.state.containerHeight : this.props.windowHeight);
const aspectRatio = Math.min(containerHeight / imageHeight, containerWidth / imageWidth);
imageHeight *= aspectRatio;
imageWidth *= aspectRatio;
// 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;
imageWidth = Math.min(imageWidth, containerWidth * maxDimensionsScale);
imageHeight = Math.min(imageHeight, containerHeight * maxDimensionsScale);
this.setState({imageHeight, imageWidth, isLoading: false});
}

Once image is cached, Image component lifecycle is onLoad => onLoadStart => onLoadEnd
Thats why isLoading is false although image is already loaded.

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

In ImageView component, need to add onLoadEnd prop in Image component usage and updates isLoading to true in onLoadEnd callback.

    <Image
        style={[
            styles.w100,
            styles.h100,
            this.props.style,

            // Hide image while loading so ImageZoom can get the image
            // size before presenting - preventing visual glitches or shift
            // due to ImageZoom
            shouldShowLoadingIndicator ? styles.opacity0 : styles.opacity1,
        ]}
        source={{uri: this.props.url}}
        isAuthTokenRequired={this.props.isAuthTokenRequired}
        resizeMode={Image.resizeMode.contain}
        onLoadStart={this.imageLoadingStart}
        onLoad={this.configureImageZoom}
        onLoadEnd={() => this.setState({isLoading: false})}
    />

And prevent to initialize image dimension in onLoadStart, no need to reset isLoading to true because it initiates by true on component loading.

    imageLoadingStart() {
        if (this.state.isLoading) {
            return;
        }
        this.resetImageZoom();
    }
Result
Screen.Recording.2023-07-15.at.7.03.08.AM.mov

What alternative solutions did you explore? (Optional)

We can prevent to invoke onLoadStart after onLoad is invoked by image caching.
If image is already loaded, imgHeight and imgWidth value is not 0.

    imageLoadingStart() {
        if (this.state.isLoading || (this.state.imgHeight !== 0 && this.state.imgWidth !== 0)) {
            return;
        }
        this.resetImageZoom();
        this.setState({imageHeight: 0, imageWidth: 0, isLoading: true});
    }

@hoangzinh
Copy link
Contributor

hoangzinh commented Jul 15, 2023

I'm not sure if it's dup with #16046

@melvin-bot melvin-bot bot added the Overdue label Jul 17, 2023
@adelekennedy adelekennedy added the External Added to denote the issue can be worked on by a contributor label Jul 17, 2023
@melvin-bot melvin-bot bot changed the title Android- infinite loading on open profile pic preview second time [$1000] Android- infinite loading on open profile pic preview second time Jul 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 17, 2023

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

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

melvin-bot bot commented Jul 17, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 17, 2023

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

@adelekennedy
Copy link

I was too fast with making this external, walking it back since this may be related to a larger issue

@melvin-bot melvin-bot bot removed the Overdue label Jul 17, 2023
@adelekennedy adelekennedy added Overdue and removed External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors labels Jul 17, 2023
@melvin-bot melvin-bot bot removed the Overdue label Jul 17, 2023
@adelekennedy adelekennedy changed the title [$1000] Android- infinite loading on open profile pic preview second time HOLD fro 18997 [$1000] Android- infinite loading on open profile pic preview second time Jul 17, 2023
@adelekennedy adelekennedy changed the title HOLD fro 18997 [$1000] Android- infinite loading on open profile pic preview second time HOLD for 18997 [$1000] Android- infinite loading on open profile pic preview second time Jul 17, 2023
@adelekennedy adelekennedy changed the title HOLD for 18997 [$1000] Android- infinite loading on open profile pic preview second time [HOLD for 18997] [$1000] Android- infinite loading on open profile pic preview second time Jul 17, 2023
@jfquevedol2198
Copy link
Contributor

I think its better to use onLoadEnd prop to resolve this issue.

@melvin-bot melvin-bot bot added the Overdue label Jul 20, 2023
@adelekennedy adelekennedy added Weekly KSv2 and removed Daily KSv2 labels Jul 20, 2023
@melvin-bot melvin-bot bot removed the Overdue label Jul 20, 2023
@adelekennedy
Copy link

deprioritizing for a mo

@melvin-bot melvin-bot bot added the Overdue label Jul 31, 2023
@adelekennedy
Copy link

still holding here

@adelekennedy
Copy link

on hold

@melvin-bot melvin-bot bot removed the Overdue label Sep 12, 2023
@melvin-bot melvin-bot bot added the Overdue label Oct 13, 2023
@melvin-bot melvin-bot bot removed the Overdue label Oct 13, 2023
@kbecciv
Copy link
Author

kbecciv commented Dec 5, 2023

The issue is reproducible on staging build 1.4.8.0, reopening @adelekennedy

Android-Avatar-preview-endless-spinner-staging.mp4

@kbecciv kbecciv reopened this Dec 5, 2023
@adelekennedy
Copy link

we're still on hold here

@melvin-bot melvin-bot bot added the Overdue label Feb 6, 2024
@adelekennedy
Copy link

not reproducible

@melvin-bot melvin-bot bot removed the Overdue label Feb 6, 2024
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. Monthly KSv2
Projects
None yet
Development

No branches or pull requests

5 participants