Skip to content
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

Switch to windows faster #62

Closed
lwouis opened this issue Oct 28, 2019 · 6 comments · Fixed by #91
Closed

Switch to windows faster #62

lwouis opened this issue Oct 28, 2019 · 6 comments · Fixed by #91

Comments

@lwouis
Copy link
Owner

lwouis commented Oct 28, 2019

Even if we ignore potential performance issues from #45, after the shortcut is released, the app is slow to switch focus to the target window.

In my tests (using a slow-mo camera), I see HyperSwitch has 3 frames between its UI disappearing, and the target window appearing. For AltTab, it's 10 frames. I'm assuming they use another way to request focus to the OS

Here is the current code (10ms):

app.activate(options: [.activateIgnoringOtherApps])
AXUIElementPerformAction(target!, kAXRaiseAction as CFString)
@lwouis lwouis added the enhancement New feature or request label Oct 28, 2019
@lwouis
Copy link
Owner Author

lwouis commented Nov 6, 2019

I looked at other open-source projects to try to see how they do it. Amethyst uses its author's Silica library for instance. I tried:

AXUIElementSetAttributeValue(target!, NSAccessibility.Attribute.main as CFString, kCFBooleanTrue)

But it's the same speed. I'm really curious how HyperSwitch does it

lwouis pushed a commit that referenced this issue Dec 20, 2019
Also adds big performance improvements to show the thumbnails and focus windows
lwouis pushed a commit that referenced this issue Dec 20, 2019
Also adds big performance improvements to show the thumbnails and focus windows
lwouis pushed a commit that referenced this issue Dec 20, 2019
Also adds big performance improvements to show the thumbnails and focus windows
lwouis pushed a commit that referenced this issue Dec 20, 2019
Also adds big performance improvements to show the thumbnails and focus windows
lwouis pushed a commit that referenced this issue Dec 20, 2019
Also adds big performance improvements to show the thumbnails and focus windows
lwouis pushed a commit that referenced this issue Dec 27, 2019
Also closes #11 closes #45 closes #62

BREAKING CHANGE: this brings huge changes to core parts of the codebase. It introduces the use of private APIs that hopefully are should be compatible from macOS 10.12+, but I couldn't test them. I reviewed the whole codebase to clean and improve on performance and readability
lwouis pushed a commit that referenced this issue Dec 27, 2019
Also closes #11 closes #45 closes #62

BREAKING CHANGE: this brings huge changes to core parts of the codebase. It introduces the use of private APIs that hopefully are should be compatible from macOS 10.12+, but I couldn't test them. I reviewed the whole codebase to clean and improve on performance and readability
lwouis pushed a commit that referenced this issue Dec 27, 2019
# [2.0.0](v1.14.4...v2.0.0) (2019-12-27)

### Features

* display other spaces/minimized windows (closes [#14](#14)) ([3f5ea25](3f5ea25)), closes [#11](#11) [#45](#45) [#62](#62)

### BREAKING CHANGES

* this brings huge changes to core parts of the codebase. It introduces the use of private APIs that hopefully are should be compatible from macOS 10.12+, but I couldn't test them. I reviewed the whole codebase to clean and improve on performance and readability
@lwouis
Copy link
Owner Author

lwouis commented Dec 27, 2019

This ticket and a bunch of others are closed in v2 released today. Feel free to test that new version out and give feedback here! Hopefully you experience better performance, can interact with minimized windows, and interact with windows from other spaces and displays. Cheers!

@lwouis
Copy link
Owner Author

lwouis commented Jan 8, 2020

Actually I was benchmarking by focusing in-and-out of the System Preferences > Privacy window, which is very slow to come up on my machine for some reason. Indeed for technique introduced in v2 is faster than even the OS when you click on the Dock icon.

However, I noticed today that for Outlook which is reasonably fast to appear, the OS is faster than AltTab. So some scenarios are faster, some of slower. I will reopen as a reminder to review this issue taking these scenarios into account

@lwouis
Copy link
Owner Author

lwouis commented Apr 8, 2020

If I count from when the menubar starts changing to Outlook's, I count:

  • AltTab: 25 frames before the Outlook window starts to appear
  • HyperSwitch: 5 frames before the Outlook window starts to appear

Some observations:

  • With AltTab, the window appears and is already ready: its 3 top-left circles are colored. With HyperSwitch, the window appears faster, but then takes many frames to get the 3 circles colored. I think this is the main way they achieve faster perceived performance here.
  • The window disappears from top to bottom, not at once. I imagine this is implementation details of my macbook internal screen, having some kind of top-to-bottom pixel repaint process.
  • The menubar starts shifting before any other UI starts changing in both cases

Here is the slowmo footage I used to compare:

Slowmo-comparison.zip

@lwouis lwouis removed the enhancement New feature or request label Jun 10, 2020
@lwouis
Copy link
Owner Author

lwouis commented Jun 10, 2020

I just did another series of tests. Note that, similar to previous tests above, the frames are frames on my 240 fps camera, not frames on my macbook 60 fps display.

Finder-to-Chrome Chrome-to-Finder Finder-to-Outlook
AltTab 12 frames 21-23 frames 16-20 frames
HyperSwitch 16 frames 16-17 frames 31 frames

@lwouis
Copy link
Owner Author

lwouis commented Jun 11, 2020

Basically at this point, I think the performance is good enough. I'll close this ticket. It's useful as a reference if we want to improve on this later on, and revisit this work.

@lwouis lwouis closed this as completed Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant