Skip to content

[Performance] Approximate the ideal number of messages to render on first paint based on the screen height #4258

@rdjuric

Description

@rdjuric

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


What performance issue do we need to solve?

This causes unnecessary renders, slow transitions between reports, slow first render of a report.

We're inefficiently guessing that we need to render 20 messages to fill our chat in the first render. In reality the ideal number of messages is based on the screen height of the user, a small chrome window or a mobile device in landscape mode might need as little as 2 messages to fill the chat.

What is the impact of this on end-users?

Chats will load faster - both when changing between chats and when first opening the app.

List any benchmarks that show the severity of the issue

Added to the benchmarks below.

Proposed solution (if any)

In our ReportActionsView, use the screenHeight to calculate the initialNumToRender of our InvertedFlatList.

We can get the ideal initialNumToRender by calculating how much screen space is available for our reports and how much screen space the smallest report possible takes.

In our ReportScreen, we render:

  • ReportActionCompose with a minHeight of 90
  • HeaderView with a height of 65
  • ReportActionsView, with the smallest report possible having 56 of height (40 for the avatar, 16 of padding)

The ideal initialNumToRender can be estimated by (screenHeight - (90 + 65)) / 56. We round the result up to account for cases where there's enough size for a part of another report to show.

List any benchmarks after implementing the changes to show impacts of the proposed solution (if any)

Benchmarks were run in dev mode, using a simulator for iOS.

  1. Start on Concierge chat
  2. Switch to another chat with 100+ messages, with 1 IOU and 2 Images in the last 20 messages
  3. Check the CONST.TIMING.SWITCH_REPORT
  4. Repeat 5 times and calculate the average
Platform initialNumToRender Average time to switch reports
Web - Chrome Fixed (20) 3,795.2 ms
Web - Chrome Ideal (7) 1,336.2 ms
iOS - iPhone SE Fixed (20) 7016 ms
iOS - iPhone SE Ideal (10) 3,888.6 ms

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number:
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Upwork URL:* https://www.upwork.com/jobs/~01a5045701b75bc097

View all open jobs on Upwork

Metadata

Metadata

Labels

DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions