Skip to content

[HOLD for Payment 2024-07-22] [$250] Improve ReportScreen rendering time #44925

@mountiny

Description

@mountiny

Problem

The Profiler indicates that the ReportScreen render time gets re-rendered dozens of times, with each re-rendering taking an average of 599.8ms.

The most current problems are with this hook:

const lastAccessedReportID = useLastAccessedReportID(!!route.params.openOnAdminRoom);

In this PR we’ve introduced the above hook and there might be several problems with it:

  1. We are calculating lastAccessedReportID in each re-render, however, we only require it in one particular scenario: when the route.params.reportID is empty,
  2. The useLastAccessedReportID hook is heavy, due to the poor performance of the ReportUtils.findLastAccessedReport function. This issue existed before the introduction of the PR mentioned.

Solution

Ad 1.
We should calculate the lastAccessedReportID only when needed, that means only once, and only when route.params.reportID is empty (code). This value is used to determine which chat we should show to the user when the user accesses the website without reportID in the URL. POC

Ad 2.
After diving deep into the code I’ve discovered that we sort a whole array of reports just to get one, the most recent, report. We can replace this sort with lodashMaxBy, as we do not (from my analysis) need to sort all reports (needs confirmation). POC

cc @kosmydel

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0109e0b5642eb1863c
  • Upwork Job ID: 1809262837407973619
  • Last Price Increase: 2024-07-05
  • Automatic offers:
    • ikevin127 | Reviewer | 103028165
Issue OwnerCurrent Issue Owner: @zanyrenney

Metadata

Metadata

Labels

AutoAssignerNewDotQualityUsed to assign quality issues to engineersAwaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions