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

Version v0.9.96 breaks hs.window.filter.new #3170

Closed
Grazfather opened this issue Mar 29, 2022 · 15 comments
Closed

Version v0.9.96 breaks hs.window.filter.new #3170

Grazfather opened this issue Mar 29, 2022 · 15 comments

Comments

@Grazfather
Copy link

Grazfather commented Mar 29, 2022

> hs.window.filter.new(nil)
2022-03-29 09:36:27: -- Loading extensions: window.filter
...merspoon.app/Contents/Resources/extensions/hs/spaces.lua:71: attempt to index a nil value (local 'contents')
stack traceback:
	...merspoon.app/Contents/Resources/extensions/hs/spaces.lua:71: in local 'getDockExitTemplates'
	...merspoon.app/Contents/Resources/extensions/hs/spaces.lua:76: in main chunk
	[C]: in function 'rawrequire'
	...poon.app/Contents/Resources/extensions/hs/_coresetup.lua:662: in function 'require'
	...n.app/Contents/Resources/extensions/hs/window_filter.lua:1530: in main chunk
	[C]: in function 'rawrequire'
	...poon.app/Contents/Resources/extensions/hs/_coresetup.lua:662: in function 'require'
	(...tail calls...)
	[C]: in function 'rawrequire'
	...poon.app/Contents/Resources/extensions/hs/_coresetup.lua:662: in function 'require'
	...merspoon.app/Contents/Resources/extensions/hs/window.lua:1027: in function <...merspoon.app/Contents/Resources/extensions/hs/window.lua:1025>
	(...tail calls...)
	[string "return hs.window.filter.new(nil)"]:1: in main chunk
	[C]: in function 'xpcall'
	...poon.app/Contents/Resources/extensions/hs/_coresetup.lua:525: in function <...poon.app/Contents/Resources/extensions/hs/_coresetup.lua:505>

Calling it with anything seems to crash. Haven't investigated.

This is on Big Sur v11.6.3, Intel

@skefy
Copy link

skefy commented Mar 29, 2022

+1

@jaidetree
Copy link
Contributor

Upgraded last night but have not run into any issues so far. Running OS X Monterey

@twio142
Copy link
Contributor

twio142 commented Mar 29, 2022

Exactly the same crash caused by window.filter on my Big Sur mac as well.

@cmsj
Copy link
Member

cmsj commented Mar 29, 2022

@Grazfather out of interest, have you previously used a tool like CleanMyMac to strip translations from macOS to save space?

I'm not really sure why spaces.lua is even involved here, but around line 71 it's trying to find a file of strings in the Dock.app bundle.

FWIW I can't reproduce the traceback you're seeing. I don't use either hs.window.filter or hs.spaces so neither is in my init.lua:

> hs.window.filter.new(nil)
2022-03-29 22:30:43: -- Loading extensions: window.filter
hs.window.filter: ... (0x600000d21d80)

@asmagill any ideas on this?

@Grazfather
Copy link
Author

Hah! I found the issue.

Instead of finding Dock.app, it's finding Docker.app, which doesn't have that file.

application("Dock"):path() is the problem.

@Grazfather
Copy link
Author

> require("hs.application")("Dock")
hs.application: Docker (0x600001373838)	hs.application: Dock (0x60000137f6b8)	hs.application: Dock Extra (0x60000137d838)```

@latenitefilms
Copy link
Contributor

Swapping it out with:

hs.application.applicationsForBundleID("com.apple.dock")[1]

...should do the trick?

@cmsj
Copy link
Member

cmsj commented Mar 29, 2022

@Grazfather aha, good catch!
@latenitefilms exactly that. Preparing a PR now :)

cmsj added a commit that referenced this issue Mar 29, 2022
… searching for 'Dock' which can match 'Docker'. Closes #3170
@Grazfather
Copy link
Author

Confirmed that that fixes the issue

> hs.window.filter.new(nil)
2022-03-29 18:10:06: -- Loading extensions: window.filter
hs.window.filter: ... (0x600001c03b80)

@cmsj cmsj closed this as completed in c6855da Mar 29, 2022
@cmsj
Copy link
Member

cmsj commented Mar 29, 2022

@Grazfather a signed dev build with the fix will appear shortly here: https://github.com/Hammerspoon/hammerspoon/actions/runs/2061396652

I would very much appreciate it if you could give it a try and confirm the fix has worked. Thanks for reporting!

@asmagill
Copy link
Member

The bundle contents of the Dock are used to determine what Mission Control calls space names when it's being displayed (so it can delete them appropriately). And yes, specifying by bundle id should fix that issue.

I wonder, though, if hs.application.find should sort the results such that exact matches come first or maybe take an optional parameter to limit it to exact matches (I just discovered that hs.application.find will take a lua style regular expression, so I should have been doing hs.application("^Dock$")).

@asmagill
Copy link
Member

And spaces is used by window filter to watch for space changes to identify windows on other spaces.

I really need to rewrite hs.window.filter now -- with the additions to hs.spaces and the addition of hs.axuielement, the module is in dire need of a complete overhaul.

@cmsj
Copy link
Member

cmsj commented Mar 30, 2022

@asmagill Any objections if I push out 0.9.97 with the current fix for this?

@asmagill
Copy link
Member

Go for it

@Grazfather
Copy link
Author

Sorry I couldn't verify with the release, but I had manually copied in the change and it was good. Downloaded the new release and I can (re) confirm that things work well.

Thanks for the quick turnaround!

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

7 participants