[HaikuDepot] Load and Unload Icons On Demand
|Reported by:||apl-haiku||Owned by:||stippi|
A significant part of the startup process of HaikuDepot is the loading of all of the icons for the packages present in the system's repository. The runtime memory overhead of all of the icons appears to be circa 8MB.
The current approach was probably sound to start with when there were few packages, but now the quantity of packages has grown the cost of loading all of the icons is no longer trivial. A better approach would be to load the icons 'on demand' from some sort of an LRU cache.
There are two situations where packages' icons are required.
The first is in the main list of packages (either "all" or "featured"). Here the logic is controlled by the class
PackageListView which is subclassing from
The second is in the lower portion of the window where packages' details are displayed. The icon there is shown next to the name in the top left corner. The class involved here is
TitleView (see PackageInfoView.cpp).
An LRU cache is used that holds a fixed number of icons; say 100 or so. Possibly the class
LocalIconStore could be modified to suit this additional functionality.
If the user scrolls fast through the list of packages then the icons would not be loaded at this high speed of scrolling. If the scrolling slows so that an icon were to be visible for > 1s or so then the icon should be loaded and should be displayed once it were loaded.
For the packages' details, the icon load should be initiated as soon as the package details are displayed. Once the icon is loaded then it should be displayed.