Skip to content

[HOLD for payment 2024-03-29] [Performance] Chat Switch Improvement Part 1 #32793

Closed

Description

@mountiny

Coming from this proposal from @hurali97

### Problem/Solution:

On Android, switching a chat takes noticeable time and doesn’t offer a good user experience. Benchmarking the main on a Mid-range android device gives us the following metrics:

Main: 7616, 7628, 7639, 7643, 7649 = 7635 ms

These durations are recorded on a debug build so we can assume that in production it’ll be shorter but that doesn’t guarantee good user experience, especially on low-end/ mid-range device. After investigating, the areas we find that this is one of the most complex piece to improve, so let’s start with what’s rather doable.

LHNOptionList leverages withCurrentReportID which adds to the rendering time and also re-rendering of the list when currentReportID is changed. The ideal solution is to put useCurrentReportID directly in the OptionRowLHNData since currentReportID is being used to evaluate isFocused prop for this component. We can save that process and do it where it’s needed to not render other parts of React tree.

When user taps on OptionRowLHNData the user navigates to the ReportScreen in that period a few unnecessary Onyx calls are being made:

First up is ComposeWithSuggestion where draft is set to false, even if it’s already set to false. Because in SilentCommentUpdater we call updateComment on mount.

Next, InteractionManager can be used to offload the work that happens before the user navigates to the ReportScreen. We can delay that work until the navigation is completed so that the user doesn’t feel that onPress is stuck.

Whole reportAction is being passed to ReportActionItem and it only uses some properties from it, so it makes sense to make it light weight and then pass it to ReportActionItem . The same concept is applied to ReportActionsList which now uses light weight report object.

Finally, there were handful unnecessary re-renders happening down the tree due to inline objects and functions 🚫
After all these improvements following is the results on debug build on the mid-range android device:

Android: 4221, 4137, 4102, 4096, 4160 = 4143.2 ms

So there’s about 3500 ms reduction in the total time, giving us around 4143.2 ms ( as compared to 7635 ms ), from when user taps on the OptionRowLHN and until the report is visible. There’s still room for improvement in this area and we will try to follow up on this with another PR.
As of now, as part of the investigation we also created the PR here, which will be ready for review after some cleanup and failing tests 🙏

P.S: some of the changes are already present in PR so they will be removed from this PR once the mentioned PR is merged.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b6dca257065e9f96
  • Upwork Job ID: 1734155699026690048
  • Last Price Increase: 2023-12-11
Issue OwnerCurrent Issue Owner: @alexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 11, 2023
  2. self-assigned this
    on Dec 11, 2023
  3. melvin-bot commented on Dec 11, 2023

    @melvin-bot

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

  4. melvin-bot commented on Dec 11, 2023

    @melvin-bot

    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
  5. hurali97 commented on Dec 11, 2023

    @hurali97
    Contributor

    @mountiny Can you assign this to me ?

  6. added
    InternalRequires API changes or must be handled by Expensify staff
    on Dec 11, 2023
  7. melvin-bot commented on Dec 11, 2023

    @melvin-bot
  8. melvin-bot commented on Dec 11, 2023

    @melvin-bot

    Current assignee @allroundexperts is eligible for the Internal assigner, not assigning anyone new.

  9. 55 remaining items

  10. alexpensify commented on Mar 30, 2024

    @alexpensify
    Contributor

    With @mountiny's feedback, here is the payment summary:

    • External issue reporter - N/A
    • Contributor that fixed the issue - @hurali97 payment handled by partner
    • Contributor+ that helped on the issue and/or PR - @allroundexperts $500 is due payment via NewDot, please submit the request

    Upwork Job: N/A

    Extra Notes regarding payment: There is regression which typically results in a decrease in pay. After reviewing this GH, these changes were complex. I'm suggesting leaving the bounty amount at the standard rate.

  11. mallenexpensify commented on Mar 31, 2024

    @mallenexpensify
    Contributor

    @alexpensify , added is due payment via NewDot, to make it clear I have the below saved as a textexpander, to help keep things consistent.

    Contributor: @ paid $ via Upwork
    Contributor+: @ owed $ via NewDot

  12. alexpensify commented on Apr 1, 2024

    @alexpensify
    Contributor

    Noted!

  13. JmillsExpensify commented on Apr 30, 2024

    @JmillsExpensify
    Contributor

    $500 approved for @allroundexperts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.InternalRequires API changes or must be handled by Expensify staffReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions