Remove Inbox from preloaded navigators to prevent CPU spike on web#84025
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
5ebaf1f to
3c3bf8e
Compare
…m-preloaded-screens
|
@hungvu193 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
|
||
| // Currently the Inbox, Workspaces and Account tabs are preloaded, while Search is not preloaded due to its potential complexity. | ||
| const TABS_TO_PRELOAD = [NAVIGATION_TABS.INBOX, NAVIGATION_TABS.WORKSPACES, NAVIGATION_TABS.SETTINGS]; | ||
| const TABS_TO_PRELOAD = [NAVIGATION_TABS.WORKSPACES, NAVIGATION_TABS.SETTINGS]; |
There was a problem hiding this comment.
I can see CPU usage deceases significantly, so 💯 to this change.
But since the most heavy tab is removed from preload tab, I wonder if we really need to preload WORKSPACES and SETTINGS tabs since they're lightweight and most of their data needed for displaying the UI of these two page come from OpenApp.
I tried to remove usePreloadFullScreenNavigators and I don't see different while switching between these tab. Do you have any metric for the usePreloadFullScreenNavigators? And what kind of data did you measured?
There was a problem hiding this comment.
@hungvu193 while I do not see much difference on Web, I can see preloading of Workspaces and Setting screens bringing good results on mobile - results when navigating from Home to Workspaces on iOS without preloading:
🔴 Duration Diff: 680.679 ms (+332.8%)
🔴 Commit Count Diff: 12
There was a problem hiding this comment.
@TMisiukiewicz Do you think we still need this preload logic on web at all?
There was a problem hiding this comment.
@hungvu193 please check this comment. I believe keeping the preloading on web makes sense for both Settings and Workspaces
|
When the preloading has been implemented it did help with performance @sumo-slonik @WojtekBoman, how come that now its showing as the reverse helps as well? |
|
Hi, I’d like to share my thoughts on the preload topic. Regarding the Settings and Workspace tabs, they do indeed run faster. Currently on web this is only noticeable during the first navigation because it has been disabled in this PR: #83887. Personally, I think we should remove this check if we want to disable preloading the Inbox tab; since these screens are light, there’s no reason not to preload them if it provides a performance gain. Because of that PR, we aren't preloading these screens when they are in the navigation state, which might be why the improvement isn't currently visible after first navigation to these screens. To show it, I recorded a video comparing the version with and without preload. To further illustrate it, I preloaded Home tab along with Settings and Account tabs and showed times when switching between them. As you can see on the video, with preloading we reach times below 100ms where without this mechanism these times are much higher than this value (approximately 2 times slower without preloading). As for the Inbox, I agree we should disable it temporarily to prevent CPU spikes. Loading data from the OpenReport API command in the background is heavy and we need to consider how to optimize it and integrate it with the preload mechanism. In the meantime, @sumo-slonik and I will investigate this further, we are currently working on reusing the navigator keys responsible for rendering tabs here.
Answering your question @mountiny, I think it's worth using this mechanism, but we need to reconsider how to optimize it in specific cases, maybe it's worth calling OpenReport when we're already navigating instead of doing it in the background. Finally, I would opt for:
Screen.Recording.2026-03-04.at.08.53.35.mov |
JmillsExpensify
left a comment
There was a problem hiding this comment.
No product review required.
|
@WojtekBoman thanks your your input! Let's do it suggested way - I'll revert it once we get this one merged and deployed to avoid the possibility of a temporary regression in between |
Preload Analysis – iOS Navigation PerformanceI have thoroughly verified the preload behavior across all navigation transitions on iOS. I am currently collecting profiler traces for the web version and will share the results in a separate message. Key ObservationThe main issue appears to be JavaScript thread overload during heavy operations (e.g., screen unmounting). In such cases, preload itself may block the JS thread, which negatively impacts performance. We should analyze when preload is triggered and ensure it runs only when the main thread has enough available capacity to handle it. Performance ResultsBelow are the averages from 5 measurements per transition, comparing preload enabled vs. disabled. 1. Navigation to Home
2. Navigation to Workspaces
3. Navigation to Account
I agree that until we improve the preload logic, we can temporarily disable preload for the Inbox. However, I would keep preload enabled for the Settings and Workspaces tabs, as their preloading is not as resource-intensive. Additionally, I suggest adding preload for the Home tab once we resolve the current JavaScript thread overload issues. After that, we should also revisit the Inbox preload and explore whether it can be made lighter — for example, by preloading only empty navigators instead of full screen content. Combined with a key reuse–based approach, preload could potentially be triggered only once per tab. After the initial preload, we would reuse the existing navigator key, eliminating the need for repeated preload executions for the same tab. ConclusionsPerformance degradation occurs primarily when navigating away from Workspaces and Reports. This is where we should focus optimization efforts. In most other scenarios, preload provides significant performance gains. When this solution was originally implemented, it clearly improved performance, so something must have changed later that introduced the regression. Recommendation
|
|
Thanks for the insight @sumo-slonik 🙏 . I'll go ahead and approve so we can move forward to the next part. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-03-03.at.21.35.02.mov |
Web – Preload ConclusionsDespite its drawbacks, based on the tests @jakubstec and I conducted, preload provides a some performance gain on Web, and in my opinion we should continue using it. Below are the average results (preload enabled vs. disabled): 1. Navigation to Home
2. Navigation to Workspaces
3. Navigation to tAccounts
SummaryBecause of this overall positive impact, I believe we should keep preload enabled on Web. At the same time, it’s important to acknowledge that preload has both advantages and drawbacks. The data clearly shows that while we gain improvements in many scenarios, there are also measurable regressions in specific transitions. The goal is not to present preload as universally beneficial, but rather to optimize how and when it runs. As the second part of my key reuse–based solution, I will ensure that preload is executed only once per tab, as mentioned earlier. With key reuse in place, we aim to:
Preload is not perfect in its current form, but with the improvements discussed (smarter triggering + key reuse), it should provide more consistent benefits and reduce the existing regressions. Overall, after these adjustments, the expected balance should be clearly more positive. |
mountiny
left a comment
There was a problem hiding this comment.
Sounds like we agree to remove it for Inbox for now and explore improvements later
|
🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.32-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.32-3 🚀
|
























Explanation of Change
When a user with many reports opens the web app on a tab other than Inbox (e.g. Workspaces or Settings), the preloading system was mounting
ReportsSplitNavigator(the Inbox navigator) in the background. This triggered a full render of the LHN with all Onyx-connected report rows, causing CPU to spike to 100% for 15–20 seconds on accounts with large report lists.The fix is straightforward: remove
NAVIGATION_TABS.INBOXfromTABS_TO_PRELOADinusePreloadFullScreenNavigators.ts. The Inbox tab doesn't need to be preloaded — it's the default tab and will mount naturally when navigated to. The remaining preloaded tabs (Workspaces and Settings) are lightweight by comparison and don't trigger the same expensive LHN render.Fixed Issues
$ #80560
PROPOSAL:
Tests
Web only
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web-preload.mov