[WIP] perf: preload the Reports tab so the first Inbox open runs the warm path - #100042
Draft
BartekObudzinski wants to merge 1 commit into
Draft
[WIP] perf: preload the Reports tab so the first Inbox open runs the warm path#100042BartekObudzinski wants to merge 1 commit into
BartekObudzinski wants to merge 1 commit into
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Contributor
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
Contributor
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
The Inbox tab is registered with
lazy: true, so nothing mountsReportsSplitNavigatoruntil the user taps Inbox for the first time. That first tap then pays for the lazy chunk, the sidebar and, on wide layouts, the centralReportScreen, all inside theManualNavigateToInboxTabspan.This adds
InboxTabWarmup, rendered by the tab bar, which callsnavigation.preload(NAVIGATORS.REPORTS_SPLIT_NAVIGATOR)in the first idle window afterOpenAppis applied. React Navigation renders a preloaded tab as iflazywerefalse, so the first tap now runs the same path as a re-visit to an already mounted tab. The dispatch happens from the tab bar because that is where the tab navigator's own navigation object lives, and its router is the one that handles the preload action.Two guards keep the preload from doing harm. It skips when Reports is the focused tab, and it skips when the route already has nested state. In both cases the router would still add the key to
preloadedRouteKeys, andBottomTabViewdropsshouldFreezefor preloaded routes, so the scene would stay unfrozen in the background despitefreezeOnBlur: true. The session flag lives ininboxTabPreloadState.tsand resets when the warm-up unmounts, because signing out unmounts the tab navigator without tearing down the JS runtime.A new
is_preloadedspan attribute records whether the session preloaded the tab, so the effect stays visible on the dashboards. It describes the session rather than the single navigation, so pair it withis_warmto isolate the first open.Measured on web in a wide layout, five cold starts each, all with
is_warm: false. Staging serves currentmain, the adhoc build serves this branch, both minified, same machine and account:main)That is -223ms on the median, or -55%. The spread matters as much as the median: staging ranges over 515ms because the first tap fetches the lazy chunk over the network, and the adhoc build ranges over 22ms because that fetch has already happened. Staging spans also carry
lazy_tab_fallback_shown: true, which the preloaded ones do not.The same comparison on a local dev bundle gave 656 -> 429 median. The dev win looks smaller in relative terms because an unminified bundle inflates both sides.
This does not make a cold open as cheap as a warm one. On web an inactive tab gets
display: none, so the preloaded scene never lays out and the LHN list renders no rows. Layout, the first row render and paint still land on the tap.Fixed Issues
$
PROPOSAL:
Tests
ManualNavigateToInboxTabspan logged in the console carriesis_preloaded: true./r/<reportID>) so the app launches with Inbox focused. Verify the report opens normally, then switch to Search and back and verify nothing is broken.Offline tests
The warm-up waits for
isLoadingAppto befalse, which a relaunch reads from disk, so it runs offline as well and builds the sidebar from the persisted collections.QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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