fix: reduce CPU usage on Manage page (#1998)#2058
Open
gauravsaini wants to merge 1 commit intoubuntu:mainfrom
Open
fix: reduce CPU usage on Manage page (#1998)#2058gauravsaini wants to merge 1 commit intoubuntu:mainfrom
gauravsaini wants to merge 1 commit intoubuntu:mainfrom
Conversation
…buntu#1998) The ManageAppActions widget was creating a full SnapModel for every installed snap tile, causing high CPU usage with 100+ snaps. Each SnapModel independently fetches data from snapd. This fix: - Uses Snap data from ManageSnapData directly for display decisions - Checks currentlyInstallingModelProvider for active changes instead of per-snap SnapModel - Only creates/reads SnapModel when an action button is actually pressed - Uses snap.apps.isNotEmpty for launchability instead of LaunchProvider
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.
Summary
Root Cause
The
ManageAppActionswidget calledref.watch(snapModelProvider(snap.name))for every snap tile, creating a fullSnapModelfor each installed snap. With 100+ snaps, this caused significant overhead as eachSnapModelindependently fetches data from snapd.Fix
Refactored
_buildSnapActionsto avoid creating per-snapSnapModelinstances on each tile:Display decisions use
Snapdata directly -refreshInhibit,apps.isNotEmpty,updateVersionare available fromManageSnapData.snapwithout needing a fullSnapModelActive changes tracked at manage page level - Uses
currentlyInstallingModelProviderinstead of per-snapSnapModel.activeChangeIdLazy SnapModel creation - Only creates/reads
snapModelProviderwhen an action button (update, open, remove) is actually pressedSimplified launchability check - Uses
snap.apps.isNotEmptyinstead ofLaunchProviderTesting
Verify that: