appDisplay: use ShellAppCache to access GAppInfo

Calls to Gio.AppInfo.get_all() can perform quite a bit of I/O on the
calling thread. This can potentially stall the compositor if the disk
controller is saturated.

Instead we can call the new ShellAppCache which contains cached information
and performs all update I/O on a thread.

Notifications of changes work very similar to GAppInfoMonitor via the
ShellAppCache::changed() signal.
This commit is contained in:
Christian Hergert 2020-02-26 23:11:33 -08:00
parent f87b9f374a
commit cfb92ad392

View File

@ -491,7 +491,7 @@ var AllView = new Lang.Class({
},
_loadApps() {
let apps = Gio.AppInfo.get_all().filter(appInfo => {
let apps = Shell.AppCache.get_default().get_all().filter(appInfo => {
try {
let id = appInfo.get_id(); // catch invalid file encodings
} catch(e) {
@ -1321,7 +1321,7 @@ var FolderIcon = new Lang.Class({
folderApps.forEach(addAppId);
let folderCategories = this._folder.get_strv('categories');
Gio.AppInfo.get_all().forEach(appInfo => {
Shell.AppCache.get_default().get_all().forEach(appInfo => {
let appCategories = _getCategories(appInfo);
if (!_listsIntersect(folderCategories, appCategories))
return;