-
Notifications
You must be signed in to change notification settings - Fork 3k
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 2024-05-06] [$500] [Wave Collect] [Ideal Nav] Chat List and Workspace List sometimes loads slowly & App sometimes hangs #35704
Comments
Triggered auto assignment to @lschurr ( |
Hey @hayata-suenaga - should this be External for contributors to work on or are we keeping this Internal? |
Job added to Upwork: https://www.upwork.com/jobs/~01e122c7e0ae0d76b5 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @cubuspl42 ( |
I'll keep this external for now. Thank you for reminding me of it 😄 |
@mountiny can you assign this to me ? 👋 |
📣 @cubuspl42 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
@hurali97 I changed the issue description of the original post of this issue to include another related issue reported about the App becoming unresponsive. Please check the issue description again and let me know if you can handle the added issue. 🙇 |
Hey @hayata-suenaga ! I took a look at the issue description and it's clear 👍 I tried to reproduce and locate the root cause but this one's tricky to reproduce. However, I found that switching between chat list and workspace is sometimes really slow. After locating the stack traces for these I found that most of the points are re-usable from the App Startup Audit on-going here. After adding the optimization code from these points, the switching between chat list and workspace is better than before by margins. However, with the fixes I left the Expensify tab open for a few minutes switched to other tab and when I came back to Expensify and reloaded the page then switched to Workspace list, I got the Unresponsiveness Alert, even with the fixes applied from the above step. It's clear that the fixes doesn't solve the root cause which is apparently related to memory consumption. I observed the memory usage whilst switching between chat list and workspaces a bunch of time the memory consumption gets to more than 2000 MB❗Upon analysing the memory allocation trace most of the allocation is consumed by I will analyse this further tomorrow and keep y'all posted 👍 |
@hayata-suenaga The ...
reportsToDisplay.forEach((report) => {
report.displayName = ReportUtils.getReportName(report);
report.iouReportAmount = ReportUtils.getMoneyRequestSpendBreakdown(report, allReports).totalDisplaySpend;
const isPinned = report.isPinned ?? false;
const reportAction = ReportActionsUtils.getReportAction(report.parentReportID ?? '', report.parentReportActionID ?? '');
// Checking for Require Attention
if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) {
pinnedAndGBRReports.push(report);
} else if (report.hasDraft) {
draftReports.push(report);
} else if (ReportUtils.isArchivedRoom(report)) {
archivedReports.push(report);
} else {
nonArchivedReports.push(report);
}
});
pinnedAndGBRReports.sort((a, b) => (a?.displayName && b?.displayName ? a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()) : 0));
... I will further investigate the cause of high memory consumption and then update with my findings here, thanks for the pointers 👍 |
@quinthar I have some break through today as I was able to locate the root cause. I also tested the fix and things are looking way better now. Switching between chat list and workspaces is snappy and I didn't encounter any sort of lag OR unresponsiveness. I switched a lot of times between them. I will post my findings here tomorrow 🤞 |
Hey guys 👋 I want to share my findings on this issue with you. This issue was relatively hard to reproduce and even if I reproduced it, it was practically impossible for me to profile the memory leaks and garbage collector not able to free the memory. The reason for that is when we are profiling for memory allocations and the web page is unresponsive, everything stops at the moment, even the profiler. So there's no way forward in that area. So I tried to profile this in chunks. To explain it, the flow this issue happens is when we are switching between chat list and workspaces. To take a chunk, we can put dummy views in chat list UI and use original view in workspaces. This gives us a chance to look for the memory issues whilst we are switching back and forth. Following this approach I started the profile process and was able to locate a bunch of very important memory issues. Let's see them in detail:
Analysing this image from memory allocation instrument, we see that the The question is the web app became kind of usable when we placed dummy UI views in the chat list area, does it mean that the The
These two variables are part of The ideal solution in such cases is to share the single source of truth for such huge data. To explain it, we can leverage
The underlying principle of I tried to profile the memory allocations by FlashList but since web page keeps getting stuck, I couldn't profile. I also tried with chunk approach by setting dummy UI in workspaces because The above image is from the docs of FlashList and as we can see that the list will perform poorly if it's slow to render. If we want to use FlashList, we will need to make the renderItem fast to render but it's hard since it's associated with lots of important data. Otherwise, we can switch to FlatList on web and still keep using FlashList on mobile platforms. Alternatively, we can use FlatList now and in a separate effort we first make renderItems fast to render and then bring back FlashList. Only case where the web page did not hang up was when I replaced FlashList with FlatList and things were back to normal. I could also profile with original UI and no hang up in that as well. Since we can't proceed with profiling, what I will deduce from this observation is point 1. Remember the HTML detached elements were not removed by GC and reports was still part of the memory? Since our LHN is based on rendering the reports, it seems to link back to the point 1. Also, since support for FlashList is in beta on web, we can think of replacing it with FlatList. Just a note, if we are to replace FlashList with FlatList and we know that now it works very well, we still should dedicate some effort in making the renderItems light weight. The above three step makes our web app a lot smoother, let's see that in action below: memory.mp4The above fixes the issue and makes our web app snappy but there are some areas that were observed during the profiling and are worth discussing over:
We have Onyx connections in our util files more than 10 times. Most of them are only used for accessing the report data. In the profiling session, we see that more than 10 times the The ideal solution we can have is either I profiled the memory after closing all the connections and kept alive only a couple and the memory allocation for objects went down by margins.
We have cache mechanism in place for We should also discuss that the cache mechanism is not useful in This is not only observed in this flow But in other flows as well. For example, as part of Callstack's audit, we analysed that in the App Startup, Send a message and Report screen load time, cache for |
Triggered auto assignment to Contributor Plus for review of internal employee PR - @ntdiary ( |
@ntdiary reassigning, please take over as C+. If you don't have bandwidth, unassign yourself. Thanks |
Upwork job price has been updated to $500 |
Unassign myself due to lack of bandwidth. :) |
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.67-7 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 2024-05-06. 🎊 For reference, here are some details about the assignees on this issue: |
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:
|
The performance regression happens with different changes and due to past architectural decisions. One change that affected this was the introduction of a cache for the sorted report IDs that required the string cache key to be compared on each render. However, because the cache key changes almost all the time, this cache wasn't used at all.
No specific PR.
https://expensify.slack.com/archives/C049HHMV9SM/p1714496660088649 |
Payment summary:
|
Bump on that offer @situchan :) |
Waiting on @situchan to accept. |
All paid! |
Action Performed:
Reported by David here, here, and here
This issue has two aspects:
The Chat List and Workspace List loads sometimes loads too slow
Another performance issue was reported by David
-> internal Slack thread where David posted the issue
The App sometimes hangs
This issue doesn't have any defined reproduction step. David reported that he sometimes get the browser popup error saying that the page is unresponsive. Please see the screenshot below. This issue was initially reported in this GH issue.
Workaround:
N/A
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Screenshot -> https://expensify.slack.com/archives/C036QM0SLJK/p1706901348693069?thread_ts=1706887969.154719&cid=C036QM0SLJK
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: