Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.13k stars 586 forks source link

hs.window.filter.new(nil) - first subscribe: 30s delay #3670

Open muescha opened 3 months ago

muescha commented 3 months ago

When

What I see

Debug


2024-08-14 20:16:56:          AppBorders: Before hs.window.filter.new(nil)
2024-08-14 20:16:56:          AppBorders: After hs.window.filter.new(nil)
2024-08-14 20:16:56:          AppBorders: before allwindows:subscribe
2024-08-14 20:17:33: 20:17:33 AppBorders: middle allwindows:subscribe
2024-08-14 20:17:33:          AppBorders: middle allwindows:subscribe
2024-08-14 20:17:33:          AppBorders: middle allwindows:subscribe
2024-08-14 20:17:33:          AppBorders: middle allwindows:subscribe
2024-08-14 20:17:33:          AppBorders: after allwindows:subscribe```
muescha commented 3 months ago

maybe it is related to:

> hs.window._timed_allWindows()
2024-08-15 19:33:09: took 0.06s for 2BUA8C4S2C.com.agilebits.onepassword4-helper
2024-08-15 19:33:09: took 0.05s for com.apple.dock
2024-08-15 19:33:09: took 0.12s for com.apple.appkit.xpc.openAndSavePanelService
2024-08-15 19:33:09: took 0.05s for mo.com.sleeplessmind.Wooshy
2024-08-15 19:33:09: took 0.07s for com.apple.HeadphoneSettings
2024-08-15 19:33:09: took 0.09s for com.apple.Family-Settings.extension
2024-08-15 19:33:09: took 0.09s for com.agilebits.onepassword4
2024-08-15 19:33:09: took 0.14s for org.pqrs.Karabiner-Elements.Settings
2024-08-15 19:33:09: took 0.08s for com.apple.wifi.WiFiAgent
2024-08-15 19:33:09: took 0.09s for com.apple.systempreferences.AppleIDSettings
2024-08-15 19:33:09: took 0.07s for N/A
2024-08-15 19:33:09: took 0.06s for com.apple.PressAndHold
2024-08-15 19:33:09: took 0.07s for com.apple.FollowUpSettings.FollowUpSettingsExtension
2024-08-15 19:33:09: took 0.06s for com.apple.NetworkExtensionSettingsUI.NESettingsUIExtension
2024-08-15 19:33:09: took 33.15s for com.apple.WebKit.WebContent
table: 0x60000268a800

> hs.window._timed_allWindows()
2024-08-15 19:35:06: took 24.03s for com.apple.WebKit.WebContent
table: 0x6000026f4240

> hs.window._timed_allWindows()
2024-08-15 19:38:38: took 24.04s for com.apple.WebKit.WebContent
table: 0x6000026cd480
```lua

the time is the same now: ~25s (:41-:16) when I do a reload:

```lua
2024-08-15 19:39:16:          AppBorders: Before hs.window.filter.new(nil)
2024-08-15 19:39:16:          AppBorders: After hs.window.filter.new(nil)
2024-08-15 19:39:16:          AppBorders: before allwindows:subscribe
2024-08-15 19:39:41: 19:39:41 AppBorders: middle allwindows:subscribe
2024-08-15 19:39:41:          AppBorders: middle allwindows:subscribe
2024-08-15 19:39:41:          AppBorders: middle allwindows:subscribe
2024-08-15 19:39:41:          AppBorders: middle allwindows:subscribe
2024-08-15 19:39:41:          AppBorders: after allwindows:subscribe
2024-08-15 19:39:41:          AppBorders: after init
muescha commented 3 months ago

did someone has an idea how to fix this?

maybe using a different filter/subscribe method?

the main idea is to get event notifications if the current focused app is changed and then draw a border around the current frontmost app