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

Ready for review - [MouseJump] Long lived background exe #28380

Merged

Conversation

mikeclayton
Copy link
Contributor

@mikeclayton mikeclayton commented Sep 5, 2023

Summary of the Pull Request

Changes the way activation works in Mouse Jump to use a long-lived background process, rather than having the main runner launch a short-lived instance of MouseJumpUI.exe every time the activation keys are pressed.

This reduces the time to display the preview popup since the Mouse Jump application itself doesn't have to load up from scratch for every activation.

PR Checklist

Detailed Description of the Pull Request / Additional comments

The main PowerToys runner now simply starts MouseJumpUI.exe when the tool is enabled, and terminates the process when the tool is disabled - this is similar to how FancyZones works, except there's no graceful IPC at present to signal to the MouseJumpUI.exe instance to close itself before it gets terminated.

The Mouse Jump C++ modulestill handles the hotkey and sends a Windows Event to the long-lived MouseJumpUI.exe to signal activation. When the UI exe receives a Windows message it displays the popup form, and hides it again when the user clicks or cancels the popup form.

Validation Steps Performed

  • Workflow tests
    • Automated tests passing locally
    • Minimal actions workflow (spelling check) passing for PR
    • Full actions workflow (msbuild) passing for PR
  • UI tests
  • Lifecycle tests
    • Starting PowerToys Runner launches MouseJumpUI.exe when enabled, and not when disabled
    • Enabling / disabling Mouse Jump in settings starts / stops MouseJumpUI.exe
    • Exiting PowerToys Runner stops MouseJumpUI.exe
    • Killing runner exe via Task Manager stops MouseJumpUI.exe
    • Stopping Visual Studio local debug run stops MouseJumpUI.exe
      • note - runner needs to be in non-admin mode otherwise Visual Studio debugger disconnects at launch
    • Hotkey and size settings are automatically reloaded when config file is modified from Settings UI
    • Hotkey and size settings are automatically reloaded when config file is modified manually (e.g. in notepad) while runner and MouseJumpUI.exe are running
  • Internal Test Suite
    • Enable Mouse Jump. Then:
    • Press the activation shortcut and verify the screens preview appears.
    • Change activation shortcut and verify that new shorctut triggers Mouse Jump.
    • Click around the screen preview and ensure that mouse cursor jumped to clicked location.
    • Reorder screens in Display settings and confirm that Mouse Jump reflects the change and still works correctly.
    • Change scaling of screens and confirm that Mouse Jump still works correctly.
    • Unplug additional monitors and confirm that Mouse Jump still works correctly.
    • Disable Mouse Jump and verify that the module is not activated when you press the activation shortcut.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@mikeclayton mikeclayton changed the title [MouseJump] Long lived background exe [MouseJump] Long lived background exe - Ready for Review Sep 5, 2023
Copy link
Collaborator

@jaimecbernardo jaimecbernardo left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the contribution @mikeclayton !
The code changes look good, but I've given it a test and found the following issues:

  • When we kill PowerToys.exe (from Task manager or just stop debugging from VS), a PowerToys.MouseJumpUI.exe process gets leaked. Something seems to be wrong with WaitForPowerToysRunner specifically for Mouse Jump. Perhaps something different needs to be called or another resource cleaned up so it exits correctly.
  • When we change a Setting like the Thumbnail size, it takes disabling and re-enabling the module for this change to take effect. Using a File Watcher like we do on other utilities may help solve this.

Please let me know if you need any help with these. 😉

@mikeclayton
Copy link
Contributor Author

@jaimecbernado - thanks for the feedback - my comments below...

When we kill PowerToys.exe (from Task manager or just stop debugging from VS), a PowerToys.MouseJumpUI.exe process gets leaked. Something seems to be wrong with WaitForPowerToysRunner specifically for Mouse Jump. Perhaps something different needs to be called or another resource cleaned up so it exits correctly.

Ah, I only tested gracefully exiting the runner with the "Exit" context menu command. I'll try this out and see how other modules are doing it...

When we change a Setting like the Thumbnail size, it takes disabling and re-enabling the module for this change to take effect. Using a File Watcher like we do on other utilities may help solve this.

Didn't even think to try this. I'll take a look and update (and add it to my regression test list 😄)...

@mikeclayton mikeclayton changed the title [MouseJump] Long lived background exe - Ready for Review [MouseJump] WIP - Long lived background exe Sep 11, 2023
@mikeclayton mikeclayton marked this pull request as draft September 11, 2023 22:30
@crutkas crutkas changed the title [MouseJump] WIP - Long lived background exe 🚧 [MouseJump] Long lived background exe Sep 24, 2023
@mikeclayton
Copy link
Contributor Author

@jaimecbernardo - the latest commit adds a FileSystemWatcher to monitor the config file (based on the same code for PowerOCR / TextExtractor).

I've not done a full regression test, but it seems to superficially work - I'll run some more tests over the next couple of days and update again once I've done that...

@jaimecbernardo
Copy link
Collaborator

Sounds good. Thank you!
By the way, here's some tests we run manually each release, from https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-utils :

Enable Mouse Jump. Then:
- Press the activation shortcut and verify the screens preview appears.
- Change activation shortcut and verify that new shorctut triggers Mouse Jump.
- Click around the screen preview and ensure that mouse cursor jumped to clicked location.
- Reorder screens in Display settings and confirm that Mouse Jump reflects the change and still works correctly.
- Change scaling of screens and confirm that Mouse Jump still works correctly.
- Unplug additional monitors and confirm that Mouse Jump still works correctly.
- Disable Mouse Jump and verify that the module is not activated when you press the activation shortcut.

@mikeclayton
Copy link
Contributor Author

@jaimecbernardo - I've worked through all the tests in the "Validation Steps Performed" section of the PR description at the top, and they all seem to work fine, including your internal Test Checklist, so I think this is now (finally) ready for review :-).

I've not tried specifically measuring the activation time, but it feels like it's a lot snappier - it would be interesting to know if it seems that way to you as well...

@mikeclayton mikeclayton changed the title 🚧 [MouseJump] Long lived background exe Ready for review - [MouseJump] Long lived background exe Oct 7, 2023
@mikeclayton mikeclayton marked this pull request as ready for review October 7, 2023 21:22
Copy link
Collaborator

@jaimecbernardo jaimecbernardo left a comment

Choose a reason for hiding this comment

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

Did plenty of testing, and it's working well for me. The issues I've encountered before seem to be gone too. Couldn't see much of a difference in terms of startup, perhaps just a bit faster, but I have a pretty powerful machine. Let's see how this pans out.
Code looks good too.
Thank you for the contribution!

I'll still fix a tiny telemetry issue I found (not caused by you, but was checking show preview code and verified the telemetry event there was wrong, so I just fixed it) and merge main in, do an installer to make sure everything is OK and after that I'll merge.

@crutkas
Copy link
Member

crutkas commented Oct 11, 2023

What is needed to get this in

@crutkas crutkas added the Needs-Review This Pull Request awaits the review of a maintainer. label Oct 11, 2023
@jaimecbernardo
Copy link
Collaborator

Just tested installer. All looks good. I'll merge after CI passes.

@jaimecbernardo jaimecbernardo merged commit 93d80f5 into microsoft:main Oct 11, 2023
7 checks passed
@mikeclayton mikeclayton deleted the dev/mikeclayton/mousejump-events branch April 25, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Review This Pull Request awaits the review of a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants