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

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

Open
muescha opened this issue Aug 14, 2024 · 2 comments
Open

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

muescha opened this issue Aug 14, 2024 · 2 comments

Comments

@muescha
Copy link
Contributor

muescha commented Aug 14, 2024

When

  • I have a script with:
     logger.i("Before hs.window.filter.new(nil)")
     allwindows = hs.window.filter.new(nil)
     logger.i("After hs.window.filter.new(nil)")
     
     --debugInfo(allwindows)
     logger.i("before allwindows:subscribe")
     --allwindows:subscribe(hs.window.filter.events, redrawBorder)
     allwindows:subscribe(hs.window.filter.windowCreated, redrawBorder)
     logger.i("middle allwindows:subscribe")
     allwindows:subscribe(hs.window.filter.windowDestroyed, redrawBorder)
     logger.i("middle allwindows:subscribe")
     allwindows:subscribe(hs.window.filter.windowFocused, redrawBorder)
     logger.i("middle allwindows:subscribe")
     allwindows:subscribe(hs.window.filter.windowMoved, redrawBorder)
     logger.i("middle allwindows:subscribe")
     allwindows:subscribe(hs.window.filter.windowUnfocused, redrawBorder)
     logger.i("after allwindows:subscribe")

What I see

  • when chrome has some more tabs. (maybe more than 50tabs), then the delay between the first and the second subscribe is about 40s, the following subscribes all without delay
  • if there is a small amount of tabs then there is not that big dealy
  • if there are more tabs (>400) there is no significant longer delay

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
Copy link
Contributor Author

muescha commented Aug 15, 2024

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
Copy link
Contributor Author

muescha commented Aug 20, 2024

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

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