[Performance] Short-circuit reportAttributes recompute on timeSkew writes#88731
Closed
adhorodyski wants to merge 1 commit intoExpensify:mainfrom
Closed
[Performance] Short-circuit reportAttributes recompute on timeSkew writes#88731adhorodyski wants to merge 1 commit intoExpensify:mainfrom
adhorodyski wants to merge 1 commit intoExpensify:mainfrom
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
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
Sibling of merged PR #88592 which dropped
ONYXKEYS.NETWORKentirely from thevisibleReportActionsderivation because that compute never readisOffline. The target here — thereportAttributesderivation atsrc/libs/actions/OnyxDerived/configs/reportAttributes.ts— does readisOfflineviagetIsOffline()from the in-memory@libs/NetworkStatemodule. The comment at line 99 (pre-change) admitted the NETWORK Onyx dep was kept purely to trigger recompute when offline state flipped.ONYXKEYS.NETWORKreceives atimeSkewwrite on every API response viasrc/libs/HttpUtils.ts:86(addSkewListmatchesOpenReport,ReconnectApp,OpenApp). Each such write fired a fullreportAttributesrecompute across all reports, which feeds LHN brick-road rendering — but the output only changes whenisOfflinebinary-edge-transitions, not on everytimeSkewupdate.Fix: short-circuit the compute when NETWORK is the sole trigger AND
isOfflineis unchanged since the last run. NETWORK stays independencies[]so genuine offline flips still invalidate and recompute.Mechanism:
previousIsOffline: boolean | undefined.sourceValuescontains onlyONYXKEYS.NETWORKas trigger andgetIsOffline() === previousIsOffline, returncurrentValueunchanged.previousIsOfflineand run the normal compute path.Why keep the NETWORK dep instead of dropping it like #88592? The downstream call chain
SidebarUtils.getReasonAndReportActionThatHasRedBrickRoad→getReceiptUploadErrorReason→getOneTransactionThreadReportActionbranches onisOffline && pendingAction === DELETE(seesrc/libs/ReportActionsUtils.tsaround line 1969). Output genuinely changes on offline flip. Dropping the dep would leave brick-road status stale until the next business-event recompute.Fixed Issues
$
PROPOSAL:
Tests
reportAttributescompute invocations.visibleReportActionsdid before [Performance] Drop dead NETWORK dependency from visibleReportActions derivation #88592; with this PR thereportAttributescompute count during warm nav drops to the number of genuine business-state triggers (usually 0–1, not N-per-API-response).Offline tests
isOfflinetransitions (i.e. the NETWORK dep is still honored for semantic changes).QA Steps
Same as Tests and Offline tests above.
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
No UI change — see span-count delta described in Tests.
Android: mWeb Chrome
No UI change — see span-count delta described in Tests.
iOS: Native
No UI change — see span-count delta described in Tests.
iOS: mWeb Safari
No UI change — see span-count delta described in Tests.
MacOS: Chrome / Safari
No UI change — see span-count delta described in Tests.