After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 698486 - Rewrite the app system to remove gnome-menus and other things
Rewrite the app system to remove gnome-menus and other things
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2013-04-21 05:14 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2014-01-17 14:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
app-system: Fix some enum warnings (1.19 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
app-system: Kill an unused warning (868 bytes, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
app-system: Use g_hash_table_iter_remove (1.46 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
app-system: Remove lookup_app_by_tree_entry (3.21 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
needs-work Details | Review
app-system: Remove last real use of shell_app_get_tree_entry (938 bytes, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
app: Port to be based on GDesktopAppInfo (11.66 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
app: Remove the use of g_desktop_app_info_launch_uris_as_manager (8.04 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
needs-work Details | Review
app-system: Remove get_tree (2.59 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
app-system: Remove known_vendor_prefixes (5.50 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
app-system: Remove lookup_app_for_path (3.41 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
needs-work Details | Review
app-system: Remove visible_id_to_app (2.65 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
appDisplay: Ignore NoDisplay categories (1.30 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
app-system: Remove use of gnome-menus internally (8.15 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
app-system: Add file monitors to monitor changes to application dirs ourselves (3.10 KB, patch)
2013-04-21 05:14 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review

Description Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:07 UTC
This finishes a branch I started long ago. Ryan eventually wants to make
a desktop file cache to improve GNOME's startup speed, but that requires
effectively dropping gnome-menus, so let's first get rid of it here.

The major change is the solidifying of ignoring NoDisplay for categories.
All other major GNOME apps use g_app_info_get_all which does not parse
the menu files.

Note that appDisplay.js has been modified, but still uses gnome-menus
for ease of implementation for now. It's possible that the categories
and Sundry grouping might move to a simpler format than the LispXML(tm)
definitions we have right now.

Some other minor changes have been made to accomodate the switch or
take into Ryan's many nitpicks of the gnome-shell code.
Comment 1 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:11 UTC
Created attachment 242053 [details] [review]
app-system: Fix some enum warnings
Comment 2 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:15 UTC
Created attachment 242054 [details] [review]
app-system: Kill an unused warning
Comment 3 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:19 UTC
Created attachment 242055 [details] [review]
app-system: Use g_hash_table_iter_remove

glib now provides an iteration-safe way to remove items from
the hash table, so use it instead of building a separate list.
Comment 4 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:22 UTC
Created attachment 242056 [details] [review]
app-system: Remove lookup_app_by_tree_entry

We want to move away from gnome-menus eventually, so the simple
utility method isn't really worth keeping around. Reimplement it
in the one place that uses it.
Comment 5 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:25 UTC
Created attachment 242057 [details] [review]
app-system: Remove last real use of shell_app_get_tree_entry

We want to replace our GMenuTreeEntries with GDesktopAppInfos
Comment 6 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:29 UTC
Created attachment 242058 [details] [review]
app: Port to be based on GDesktopAppInfo

We weren't using the GMenuTreeEntry for anything special anymore,
so remove it.
Comment 7 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:33 UTC
Created attachment 242059 [details] [review]
app: Remove the use of g_desktop_app_info_launch_uris_as_manager

... and at the same time, remove tracking windows by launched PID.
It will fail working after a Shell restart, and Ryan wants to
remove the method as it's racy and not a great idea.
Comment 8 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:37 UTC
Created attachment 242060 [details] [review]
app-system: Remove get_tree

Make clients construct their own gmenu tree if they need it.
Comment 9 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:40 UTC
Created attachment 242061 [details] [review]
app-system: Remove known_vendor_prefixes

This does remove support for legacy prefixed app infos with
subdirs, but since we want to remove support for the menu spec,
let's not even bother.
Comment 10 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:44 UTC
Created attachment 242062 [details] [review]
app-system: Remove lookup_app_for_path

It's absurdly silly. Just modify the one place that uses it
to be better.
Comment 11 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:47 UTC
Created attachment 242063 [details] [review]
app-system: Remove visible_id_to_app

Since appDisplay.js makes its own GMenu tree, it's not necessary
anymore. This does mean that searches will show apps in NoDisplay
categories, but that's an obscure enough edge case not to matter.
Comment 12 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:51 UTC
Created attachment 242064 [details] [review]
appDisplay: Ignore NoDisplay categories

This makes us match the native app search.
Comment 13 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:55 UTC
Created attachment 242065 [details] [review]
app-system: Remove use of gnome-menus internally

We want to transition to a system in the future where we have a desktop
file cache. As we no longer differentiate categories or similar, it no
longer makes sense to have app visibility based on categories. Thus,
we no longer need to use gnome-menus to list all apps. The potential
issue here is reloading all desktop files when new files are created,
but this can be dealt with individually.

The "All Applications" view still uses gnome-menus.
Comment 14 Jasper St. Pierre (not reading bugmail) 2013-04-21 05:14:59 UTC
Created attachment 242066 [details] [review]
app-system: Add file monitors to monitor changes to application dirs ourselves

Cheaply and easily monitor changes to the application dirs to tell us
when a desktop file has been created, changed, or removed. Note that this
also not 100% spec compliant -- subdirectories of application dirs aren't
recognized and properly prefixed. Given the relative obscurity of this
scenario in the specification, and that restarting gnome-shell, I'm fine
with the code clarity of not having to recursively set up file monitors.
Comment 15 Giovanni Campagna 2013-04-21 13:01:49 UTC
May I say I disagree with this whole patchset?

- A category based menu is still needed in classic mode, so GMenu is a hard dependency of GNOME anyway
- NoDisplay categories are heavily used in Debian systems, and removing support for them would cause duplicate applications
- All KDE applications install themselves in /usr/share/applications/kde4, so recursive file monitors and known_vendor_prefixes are needed
- launch_uris_as_manager is the only way to associate apps that don't have a desktop file, or that use the wrong wm_class; it's not racy at all: yes the app can map the window before we get scheduled from fork(), but we won't get the MapRequest event until long after that
- The XML menu spec is a standard that all desktops and ISVs support, having a new GNOME specific thing for folders would not benefit us or anyone
Comment 16 Jasper St. Pierre (not reading bugmail) 2013-04-21 13:28:26 UTC
(In reply to comment #15)
> May I say I disagree with this whole patchset?
> 
> - A category based menu is still needed in classic mode, so GMenu is a hard
> dependency of GNOME anyway

And we can use it from GIR, as we do right now with appDisplay. But like some other Classic-only technologies, we can use it from Classic and nothing else. The app system specifically does not need to use GMenu.

> - NoDisplay categories are heavily used in Debian systems, and removing support
> for them would cause duplicate applications

Should we fix this in every app that currently uses g_app_info_get_all()? That doesn't parse the menu spec, so you'll potentially get duplicate applications in e.g. the Notifications panel as well, right?

I don't know much about how Debian has their crazy menu stuff set out; but that sounds to me more like an OnlyShowIn/NotShowIn thing. What's their rationale for using NoDisplay categories?

> - All KDE applications install themselves in /usr/share/applications/kde4, so
> recursive file monitors and known_vendor_prefixes are needed

I didn't know about this, but I can re-add it. I'll probably add the APIs to watch the directories in gio, as would be getting a bit more complex.

> - launch_uris_as_manager is the only way to associate apps that don't have a
> desktop file, or that use the wrong wm_class; it's not racy at all: yes the app
> can map the window before we get scheduled from fork(), but we won't get the
> MapRequest event until long after that

But it breaks when we restart the shell, or if we have apps that are started from any other service (DBus activation, systemd, gnome-terminal, anything which launches "a file"), which we'll have more of in the future. Unless you think Firefox should be changed to tell the shell what to spawn.

The race that can happen is that if somebody uses GtkApplication, it quickly starts up, sends a DBus message, and then quits again. It's likely that the child has exited before we have installed the child watch on its PID, meaning we have a rogue PID around. Ryan also wants to make that function basically break in the future, so even if nothing else lands, it's still one thing I think we should land.

> - The XML menu spec is a standard that all desktops and ISVs support, having a
> new GNOME specific thing for folders would not benefit us or anyone

I don't think the XML menu spec is really applicable to the overview in terms of where we're going, where we want users to be able to make folders on their own. I'd rather have that tracked in GSettingsList than trying to manipulate the XML menu spec to do what we want. I maintain alacarte; I know exactly what kind of crazy workarounds it employs to make simple things like reordering items happen, and I don't think it's a good idea.

The XML menu spec isn't really an ISV API: Wine and alacarte both want to write to the applications.menu override file, and they're both super careful not to trample on anything else. The way they have to do this is to read the entire menu (/etc/xdg/menus/applications.menu and ~/.local/share/xdg/menus/applications.menu) and try to figure out what it wants to write to not mess up the user's existing system. It's an extremely fragile system, and Wine does it so it can install a submenu in the GNOME 2 menu, which we ignore in GNOME 3.

And *if* the ISV manages to write the extremely fragile code that does all that stuff, it won't appear in the overview anyway unless they tweak a default key right now. I'd say that we've already been on life support for supporting much of the menu spec, and it's much better off forgotten about.
Comment 17 Giovanni Campagna 2013-04-24 19:12:06 UTC
    JS ERROR: !!!   Exception was: TypeError: itemB is null
    JS ERROR: !!!     message = '"itemB is null"'
    JS ERROR: !!!     fileName = '"/opt/gnome/share/gnome-shell/js/ui/appDisplay.js"'
    JS ERROR: !!!     lineNumber = '255'
    JS ERROR: !!!     stack = '"AllView<._compareItems@/opt/gnome/share/gnome-shell/js/ui/appDisplay.js:255
wrapper@/opt/gnome/share/gjs-1.0/lang.js:213
AlphabeticalView<.loadGrid@/opt/gnome/share/gnome-shell/js/ui/appDisplay.js:101
wrapper@/opt/gnome/share/gjs-1.0/lang.js:213
AppDisplay<._redisplayAllApps@/opt/gnome/share/gnome-shell/js/ui/appDisplay.js:452
wrapper@/opt/gnome/share/gjs-1.0/lang.js:213
_runDeferredWork@/opt/gnome/share/gnome-shell/js/ui/main.js:703
_runBeforeRedrawQueue@/opt/gnome/share/gnome-shell/js/ui/main.js:718
@/opt/gnome/share/gnome-shell/js/ui/main.js:727
Comment 18 Jasper St. Pierre (not reading bugmail) 2013-05-09 02:02:07 UTC
Giovanni, can you review some of the initial cleanup patches? Ryan has assured me he'll introduce a desktop file cache upstream sometime soon, so I'll be rewriting most of this to use that instead.
Comment 19 Giovanni Campagna 2013-05-09 10:50:02 UTC
Ok, I'll review, but I've seen crashes in libgnome-menus testing this, so we may want to hold on a bit (unfortunately I didn't have time to debug them)
Comment 20 Giovanni Campagna 2013-05-09 10:50:02 UTC
Ok, I'll review, but I've seen crashes in libgnome-menus testing this, so we may want to hold on a bit (unfortunately I didn't have time to debug them)
Comment 21 Giovanni Campagna 2013-05-09 10:51:12 UTC
Review of attachment 242053 [details] [review]:

::: src/shell-app-system.c
@@ +566,3 @@
     {
     case SHELL_APP_STATE_RUNNING:
+    case SHELL_APP_STATE_BUSY:

If the app goes from running to busy, it's already in the table, no?
Comment 22 Giovanni Campagna 2013-05-09 10:51:35 UTC
Review of attachment 242054 [details] [review]:

Yes
Comment 23 Giovanni Campagna 2013-05-09 10:51:58 UTC
Review of attachment 242055 [details] [review]:

Nice.
Comment 24 Giovanni Campagna 2013-05-09 10:57:14 UTC
Review of attachment 242056 [details] [review]:

::: js/ui/appDisplay.js
@@ +45,3 @@
             let entry = iter.get_entry();
+            let appInfo = entry.get_app_info();
+            let app = appSystem.lookup_app(appInfo.get_id());

This one is broken until we get appInfo.get_id() to respect subdirectories in /usr/share/applications. And that's a blocker for me.
Comment 25 Giovanni Campagna 2013-05-09 10:58:17 UTC
Review of attachment 242057 [details] [review]:

Ok
Comment 26 Giovanni Campagna 2013-05-09 11:01:18 UTC
Review of attachment 242058 [details] [review]:

::: src/shell-app.c
@@ +895,2 @@
 {
+  g_clear_object (&app->info);

Can it happen that info is set twice on the same app?
If not, it might be nice to avoid the atomic set, we call this a lot at startup.
Comment 27 Giovanni Campagna 2013-05-09 11:03:28 UTC
Review of attachment 242059 [details] [review]:

As noted before, the method is not racy, and it's not a common use case to restart the shell, while it is common to have apps with wrong WM_CLASS. I'm against this.
Comment 28 Giovanni Campagna 2013-05-09 11:06:11 UTC
Review of attachment 242060 [details] [review]:

Uhm squash this with the patch that removes internal gmenu usage.
Comment 29 Giovanni Campagna 2013-05-09 11:10:47 UTC
Review of attachment 242061 [details] [review]:

Virtually all KDE4 applications have a desktop file id like 'kde4-something.desktop', but they're wm class is just Something, so they're going to regress if you remove this.
At least, please extend the hard coded vendor_prefixes with "kde-", "kde4-", "crx-" (chrome) and "wine-".
Comment 30 Giovanni Campagna 2013-05-09 11:14:17 UTC
Review of attachment 242062 [details] [review]:

::: src/shell-window-tracker.c
@@ +677,3 @@
   appsys = shell_app_system_get_default ();
+  app = shell_app_system_lookup_app (appsys, basename);
+  g_free (basename);

According to the startup notification spec, the application_id field is a full path name only when the desktop file is in a nonstandard location, so calling get_basename is never useful here.
Comment 31 Giovanni Campagna 2013-05-09 11:15:34 UTC
The rest are not cleanups, they're a full refactoring, and they change behavior too, so I'll leave them for now.
Comment 32 Jasper St. Pierre (not reading bugmail) 2013-05-12 18:45:03 UTC
Attachment 242054 [details] pushed as c8792cc - app-system: Kill an unused warning
Attachment 242055 [details] pushed as 0fd6ae5 - app-system: Use g_hash_table_iter_remove
Comment 33 Jasper St. Pierre (not reading bugmail) 2013-05-12 18:46:15 UTC
Comment on attachment 242057 [details] [review]
app-system: Remove last real use of shell_app_get_tree_entry

Attachment 242057 [details] pushed as c72ae37 - app-system: Remove last real use of shell_app_get_tree_entry
Comment 34 Jasper St. Pierre (not reading bugmail) 2013-05-12 18:52:08 UTC
(In reply to comment #26)
> Can it happen that info is set twice on the same app?

Yes. If somebody modifies the .desktop file, we'll re-create the GDesktopAppInfo since our file monitor went off, but we won't recreate the ShellApp.
Comment 35 Jasper St. Pierre (not reading bugmail) 2013-10-02 13:49:47 UTC
Comment on attachment 242053 [details] [review]
app-system: Fix some enum warnings

Attachment 242053 [details] pushed as 3a4782c - app-system: Fix some enum warnings
Comment 36 Colin Walters 2013-11-03 20:32:13 UTC
Current Continuous buildmaster is crashing with the following stack, pretty sure it's these changes.

Thread 1 (Thread 0x7ffff7fae900 (LWP 1427))

  • #0 g_type_check_instance_cast
    at ../../gobject/gtype.c line 4003
  • #1 shell_app_get_id
    at ../../src/shell-app.c line 141
  • #2 shell_app_system_lookup_app
    at ../../src/shell-app-system.c line 144
  • #3 ffi_call_unix64
    from /lib/libffi.so.6
  • #4 ffi_call
    from /lib/libffi.so.6
  • #5 gjs_invoke_c_function
    at ../gi/function.cpp line 894