Skip to content

[Bug]: App specific triggers sometimes do not work right after starting the app. #2919

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

Closed
3 tasks done
dhoepfl opened this issue Aug 16, 2022 · 1 comment
Closed
3 tasks done

Comments

@dhoepfl
Copy link
Contributor

dhoepfl commented Aug 16, 2022

Before submitting your bug report, please confirm you have completed the following steps

Bug description

I have a trigger who's scope is limited to one app.
When I start this app, the trigger does not reliably work.
It does work after I switched to a different app and returned to the specific app.

Steps to reproduce

  1. Add a trigger
  2. Limit its scope to an App
  3. Start the App
  4. Try the trigger

Expected behavior

The trigger should work each time.

MacOS Version

macOS 12

Quicksilver Version

Checked out main/Released 2.4.0 (4039)

Relevant Plugins

-/-

Crash Logs or Spindump

-/-

Screenshots

-/-

Additional info

  1. QSProcessMonitor.m handles both appChanged (line 51) and appLaunched (line 70) carbon process events.
  2. The appLaunched handler schedules an async task on the main thread that posts a notifications on the default notification center.
  3. This notification is handled in the future on the main thread and updates the processesDict (in reloadProcesses, line 362).
  4. The appChanged handler might be called before step 3 takes place. appChanged uses processObjectWithPSN to get the process information for the newly active app which is not yet stored in processesDict. The result of this call is attached as user info to another notification posted (one of the listeners to this notification updates which triggers are active).

Since in step 4, the processesDict has not been updated in all cases, the newly active app is not known and the triggers do not get updated.

Note: appLaunched calls processObjectWithPSN (in line 80) using the PSN of the new app. This call always returns nil.

I see two ways to fix this:

  1. Lazy fix: Drop the call to processObjectWithPSN in appLaunched carbon event handler and move the call to processObjectWithPSN onto the main thread in appChanged.

  2. Clean fix: reloadProcesses mentions a addProcessWithPSN which I could not find. If this existed, it should be called in appLaunched (instead of line 80, if it returns the new dictionary) to update the processesDict right away. Everything else could stay the same.

@dhoepfl
Copy link
Contributor Author

dhoepfl commented Aug 18, 2022

See pull request #2921.

pjrobertson added a commit that referenced this issue Aug 19, 2023
pjrobertson added a commit that referenced this issue Aug 21, 2023
Switch to NSRunningApplications in QSProcessMonitor. Fixes #2919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant