Skip to content

feat: Replace JS launcher service with Rust launcher service #1139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 30, 2021
Merged

Conversation

mmstick
Copy link
Member

@mmstick mmstick commented Aug 13, 2021

Requires package of https://github.com/pop-os/launcher to be installed

Removes a lot of JavaScript code. The UI code for the launcher remains, but all of the launcher filtering, sorting, and plugin management now exists in a separate Rust process. The launcher UI spawns the pop-launcher process and asynchronously listens to its responses while sending launcher events to it.

Some new DBus methods were added for the pop-shell plugin written for the launcher.

There is also fix for some window focusing issues. A window will now be activated through its workspace. It may be a GNOME 40 thing, but workspace shifting will not happen if you are activating a window directly. There is also a chance that a window being requested to activate does not actually have a clutter actor attached to it, so there's a check for that.

Closes #1141
Closes #1135
Closes #1108
Closes #995
Closes #903
Closes #849
Closes #199
Closes #1087

@mmstick mmstick marked this pull request as ready for review August 13, 2021 19:18
@mmstick mmstick requested review from a team August 13, 2021 19:18
@jacobgkau
Copy link
Member

jacobgkau commented Aug 13, 2021

The Shell extension isn't starting after updating to this branch (and pulling in the pop-launcher dependency) on Hirsute:

Aug 13 14:00:25 pop-os gnome-shell[3293]: JS ERROR: Extension [email protected]: Error: Schema org.gnome.shell.extensions.pop-shell could not be found for extension [email protected]. Please check your installation
                                          getSettings@resource:///org/gnome/shell/misc/extensionUtils.js:151:15
                                          log_level@/usr/share/gnome-shell/extensions/[email protected]/log.js:11:35
                                          info@/usr/share/gnome-shell/extensions/[email protected]/log.js:27:9
                                          init@/usr/share/gnome-shell/extensions/[email protected]/extension.js:1914:9
                                          _callExtensionInit@resource:///org/gnome/shell/ui/extensionSystem.js:435:50
                                          loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:348:27
                                          _loadExtensions/<@resource:///org/gnome/shell/ui/extensionSystem.js:597:18
                                          collectFromDatadirs@resource:///org/gnome/shell/misc/fileUtils.js:27:28
                                          _loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:572:19
                                          _enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:606:18
                                          _sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:637:18
                                          init@resource:///org/gnome/shell/ui/extensionSystem.js:57:14
                                          _initializeUI@resource:///org/gnome/shell/ui/main.js:272:22
                                          start@resource:///org/gnome/shell/ui/main.js:162:5
                                          @<main>:1:47

Also, it looks like https://github.com/pop-os/launcher failed to build on Focal (this log is from the build server):

cargo build -p pop-launcher-plugins --release --frozen --offline
error: failed to get `flume` as a dependency of package `pop-launcher-plugins v1.0.0 (/<<PKGBUILDDIR>>/plugins)`
Caused by:
  failed to load source for dependency `flume`
Caused by:
  Unable to update registry `https://github.com/rust-lang/crates.io-index`
Caused by:
  failed to update replaced source registry `https://github.com/rust-lang/crates.io-index`
Caused by:
  failed to parse manifest at `/<<PKGBUILDDIR>>/vendor/zvariant/Cargo.toml`
Caused by:
  feature `resolver` is required
  consider adding `cargo-features = ["resolver"]` to the manifest

@mmstick mmstick force-pushed the launcher branch 4 times, most recently from ac1c272 to a77b178 Compare August 16, 2021 12:23
@jacobgkau
Copy link
Member

jacobgkau commented Aug 16, 2021

On a77b178, I am seeing the window list fail to load fairly often when only one window is open:

Screenshot from 2021-08-16 08-12-50

If I close and re-open the launcher a few times, then the single open window does sometimes show up in the list:

Screenshot from 2021-08-16 08-15-13

@jacobgkau
Copy link
Member

Also, if I search and then clear the search text, the window list does not re-show.

@mmstick
Copy link
Member Author

mmstick commented Aug 17, 2021

The latest version of pop-launcher has fixed the issue. The channel crate that I was using was sending messages out of order. Switched to a different crate which pops messages in the order they were pushed.

@mmstick mmstick force-pushed the launcher branch 7 times, most recently from ce5690f to cde3b01 Compare August 17, 2021 15:34
@mmstick
Copy link
Member Author

mmstick commented Aug 17, 2021

Context option support (right click popup menu) has been reimplemented for desktop entries.

@mmstick mmstick force-pushed the launcher branch 2 times, most recently from 9605860 to 44846ec Compare August 17, 2021 15:45
@jacobgkau
Copy link
Member

The search results seem to hide and then re-show every time I add a character to the search, which results in flickering:

simplescreenrecorder-2021-08-18_08.37.33.mp4

Can we keep the old results on the screen until the new results are ready to display so this doesn't happen?

@mmstick mmstick force-pushed the launcher branch 2 times, most recently from 204ce67 to 890cc89 Compare August 18, 2021 16:09
@jacobgkau
Copy link
Member

When I first open the launcher, the first search result (which is selected by default) is a window, but the window is not highlighted like it should be:

Screenshot from 2021-08-18 12-20-53

If I move down and then back up in the results list, the window becomes highlighted:

Screenshot from 2021-08-18 12-20-56

@jacobgkau
Copy link
Member

If I have a Settings page open, switch to a different workspace, then launch a different settings page through the Launcher, I get a "Settings" is Ready notification, but the workspace does not switch so I can see the Settings window like it used to.

@jacobgkau
Copy link
Member

The search is not being cleared properly when I exit the launcher. For example, if I start with no windows open:

Screenshot from 2021-08-19 10-30-55

Perform a search:

Screenshot from 2021-08-19 10-34-11

Then exit the launcher with ESC, then open it again:

Screenshot from 2021-08-19 10-31-11

Now my search box is empty but I'm still seeing results from that search. Attempting to click on those results doesn't work, I need to enter something into the search box before the results are clickable/selectable. Also, the launcher opened up higher on the screen, which seems like an issue.

One other thing I noticed, the calculator search results now include a "by Qalc" message:

Screenshot from 2021-08-19 10-29-41

We didn't have a "by MathJS" message before, so I'm wondering if this is necessary to add. I'm not opposed to giving credit to other projects where it's due, but having it prominently in the UI like that might be a UX thing. (It looks like the actual name of the program/project is Qalculate!, and the command qalc is referred to either all-lowercase or all-caps in its man page, so the branding we're using also isn't super clear.)

@mmstick
Copy link
Member Author

mmstick commented Aug 19, 2021

The description could be empty, but I figured that showing the name would indicate what you should search to find more information about it's specific math expression syntax. The syntax is virtually identical to Math.JS though.

@mmstick mmstick closed this Aug 20, 2021
@mmstick
Copy link
Member Author

mmstick commented Aug 23, 2021

The next version of the launcher will add support for prioritizing results from a plugin, and the web plugin will request a high priority (priority: High) so that it's search results always get bumped to the top.

@jacobgkau
Copy link
Member

If I choose Power Off, Restart, or Log Out, the launcher does not close and the 60-second confirmation dialog shows up behind the launcher:

Screenshot from 2021-08-24 12-12-11

This is happening on both 21.04 and 20.04.

@mmstick
Copy link
Member Author

mmstick commented Aug 24, 2021

I see. The standard output stream is getting closed before it signals to the launcher to close.

@mmstick
Copy link
Member Author

mmstick commented Aug 24, 2021

Latest version of the launcher will have fixed that issue.

@jacobgkau
Copy link
Member

jacobgkau commented Aug 24, 2021

It looks like pop-launcher 3be27dd failed to build on the build server:

The following warnings were emitted during compilation:
warning: Failed to run `"pkg-config" "--libs" "--cflags" "glib-2.0" "glib-2.0 >= 2.48"`: No such file or directory (os error 2)
error: failed to run custom build command for `glib-sys v0.14.0`
Caused by:
  process didn't exit successfully: `/<<PKGBUILDDIR>>/target/release/build/glib-sys-de38c82711b78786/build-script-build` (exit code: 1)
  --- stdout

It also failed to build locally on a Hirsute machine, but with cairo in the error message instead of glib-2.0.

@jacobgkau
Copy link
Member

pop-launcher version 1468f74 will not install because it depends on libgtk-3.0, which does not exist.

@jacobgkau
Copy link
Member

On pop-launcher 07b740a, opening a new window of an application that's already open does not work. An existing window of the application is focused when I try to open a new window. This can be recreated with Terminal, Files, and Firefox.

If I had to guess, this may have broken when the Settings focusing/workspace-switching behavior was added (it looks/feels like something similar happening.) Settings is a special case because it can't have multiple windows open, but most apps can.

@mmstick
Copy link
Member Author

mmstick commented Aug 25, 2021

I do have it opting to focus application windows of the existing window by default, and only launching a new window if a window didn't already exist. Which is the behavior of GNOME's application launcher.

I can switch it back to defaulting to always attempting to launch non-Settings window, but there are more applications that use GtkApplication to prevent an application from having more than one window.

@jacobgkau
Copy link
Member

I do have it opting to focus application windows of the existing window by default, and only launching a new window if a window didn't already exist. Which is the behavior of GNOME's application launcher.

That behavior makes (at least a little) sense for the Applications menu, because that menu has dot indicators under the icons of apps that are already running. That menu also allows a Ctrl-Click to force open a new window/instance. In the Launcher, we already explicitly list open windows separately from app launchers, and the app launcher icon is a window with a plus sign, which pretty clearly indicates (to me, at least) that it's supposed to open a new window. So I'd go back to the old/current behavior on that for the time being, with Settings as the only exception (or Settings and any others that you're aware of that would need this.)

If we moved forward with changing this behavior to no longer launch a new window/instance, then we'd probably have to change the icon and also add a way (e.g. Ctrl-Enter or Ctrl-Click) to launch a new window/instance manually when desired. (I did bring this up in #1001, although the need was a little different there.)

@mmstick
Copy link
Member Author

mmstick commented Aug 25, 2021

Found a way to achieve this, though it's a bit of a hack. It's tricky because launching an app via the launch() method on a Shell.App does not focus the newly-opened window. Getting a Shell.AppInfo from a Shell.App and using the launch() method on that works, but that launch method doesn't support the GPU preference options we send it. And to make matters worse, it takes an unknown amount of time before the newly-launched window appears in the get_windows() method of Shell.App(), if it ever does.

@jacobgkau
Copy link
Member

The current approach is not working. I'm frequently getting windows opening up behind the focused window:

Screenshot from 2021-08-26 09-47-37

How is this working in the master branch currently, was it handled by something that has now been moved to the pop-launcher service?

@mmstick
Copy link
Member Author

mmstick commented Aug 26, 2021

In master, the GPU preference is being ignored.

@jacobgkau
Copy link
Member

2f98afd hasn't corrected the issue, new windows still open behind the focused window.

@mmstick
Copy link
Member Author

mmstick commented Aug 26, 2021

Is there a certain way to trigger this? Can't seem to get my windows to do that.

@jacobgkau
Copy link
Member

On an Oryx Pro in NVIDIA mode, I'm just opening up one terminal, enlarging the window, and then opening up another terminal:

Screencast.from.08-26-2021.01.40.57.PM.mp4

I can do the same thing with Firefox.

@mmstick
Copy link
Member Author

mmstick commented Aug 27, 2021

Replicated and resolved

@jacobgkau
Copy link
Member

New windows open and are focused as expected now. We're still getting a brief ___ is ready notification when opening new windows:

simplescreenrecorder-2021-08-27_09.18.29.mp4

This notification is disappearing very quickly, almost too quickly for the user to read. I can see this being a confusion and/or distraction, especially for users installing the update who aren't used to seeing this. Is there a way to suppress those?

@jacobgkau
Copy link
Member

jacobgkau commented Aug 27, 2021

I noticed that the Pop!_Shop no longer shows up in the search results for shop:

Screenshot from 2021-08-27 12-07-51

I'm assuming this is due to pop-os/launcher@b5514a6. That change is definitely an improvement to search results overall (it closes #1087), but shop returning the Pop!_Shop first is one of the items on our regression checklist, and I would generally expect it to work.

  • It looks like the reason why Keyboard is so high up in the results for shop is because the word shortcuts within the comment line is matching. Can we prioritize Name over Comment in sorting? This might get the shop back into the first page of search results.
  • Separately, Since Pop!_Shop is presumably matching lower because it's all one word, maybe punctuation (e.g. the underscore) should be treated the same as a space when breaking words apart for sorting purposes? This would presumably bring the shop back to the first result.

@mmstick
Copy link
Member Author

mmstick commented Aug 27, 2021

We can definitely tweak the parameters until we find the right match

@mmstick
Copy link
Member Author

mmstick commented Aug 27, 2021

The latest commit to the launcher will also split _ the same as whitespace, so Shop will be on top again.

Copy link
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not seeing any more issues as compared to the current JS launcher. Regression testing has passed:
shell-pr1139-hirsute.txt - with pop-launcher version 5e2c38e.
shell-pr1139-focal.txt - with pop-launcher version 777fe78 (the only change between this version and 5e2c38e were comments and documentation files regarding licensing.)

Once this pop-shell PR is merged, future changes to pop-launcher will need to go through PRs instead of being pushed straight to master.

@mmstick mmstick merged commit 0484ffb into master Aug 30, 2021
@mmstick mmstick deleted the launcher branch August 30, 2021 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment