Closed folke closed 4 years ago
If I replace the checks for watcher._element.pid
to watcher:element() and watcher:pid()
on line 1431 and line 1390 in extensions/hs/window/filter.lua
, then everything starts working again.
However, after that, reloading the config segfaults the hammerpsoon process, but this might be unrelated:
2020-09-20 21:24:42.002 Hammerspoon[70193:1203413] destroyLuaState
ERROR: SentryCrashMachineContext.c (230): void sentrycrashmc_resumeEnvironment(): thread_resume (00008f07): (os/kern) invalid argument
fish: '/Applications/Hammerspoon.app/C…' terminated by signal SIGSEGV (Address boundary error)
Another output:
2020-09-20 21:31:37.529 Hammerspoon[70492:1207876] destroyLuaState
ERROR: SentryCrashCPU.c (58): _Bool sentrycrashcpu_i_fillState(const thread_t, const thread_state_t, const thread_state_flavor_t, const mach_msg_type_number_t): thread_get_state: (ipc/send) invalid destination port
ERROR: SentryCrashCPU.c (58): _Bool sentrycrashcpu_i_fillState(const thread_t, const thread_state_t, const thread_state_flavor_t, const mach_msg_type_number_t): thread_get_state: (ipc/send) invalid destination port
ERROR: SentryCrashMachineContext.c (230): void sentrycrashmc_resumeEnvironment(): thread_resume (ffffffff): (ipc/send) invalid destination port
fish: '/Applications/Hammerspoon.app/C…' terminated by signal SIGSEGV (Address boundary error)
Same issue on catalina.
If I'm reading the source correctly, both 1431 and 1390 should be just watcher:pid()
but I can confirm that even that results in a crash on reload. I'll dig deeper.
Any of you who are comfortable building your own Hammerspoon build, please take a look at #2483.
I was able to successfully run the example given above and restart without a crash, but I don't regularly use hs.window.filter
or anything that does, so I really don't know what to do to test further.
If you can test this out, please let me know your results. I'll see if I can come up with some other tests on my own as well.
Hi. The same thing happens to me after updating hammerspoon.
Hammerspoon Console
2020-09-21 13:27:32: -- Loading extension: window
2020-09-21 13:27:32: -- Loading extensions: window.filter
2020-09-21 13:27:32: *** ERROR: ...n.app/Contents/Resources/extensions/hs/window/filter.lua:1431: attempt to index a nil value (field '_element')
stack traceback:
...n.app/Contents/Resources/extensions/hs/window/filter.lua:1431: in upvalue 'startAppWatcher'
...n.app/Contents/Resources/extensions/hs/window/filter.lua:1559: in upvalue 'startGlobalWatcher'
...n.app/Contents/Resources/extensions/hs/window/filter.lua:1722: in upvalue 'start'
...n.app/Contents/Resources/extensions/hs/window/filter.lua:1913: in method 'subscribe'
/Users/ahaljh/.hammerspoon/init.lua:111: in main chunk
[C]: in function 'xpcall'
...app/Contents/Resources/extensions/hs/_coresetup/init.lua:702: in function 'hs._coresetup.setup'
(...tail calls...)
part of init.lua that called window.filter
finderHotkey = hs.hotkey.bind({'ctrl', 'cmd'}, 'e', function()
local curAppName = hs.application.frontmostApplication():name()
if curAppName ~= "Citrix Viewer" then
hs.execute('open ~')
else
finderHotkey:disable() -- does not work without this, even though it should
hs.eventtap.keyStroke({'ctrl', 'cmd'}, 'e')
--hs.timer.doAfter(10, finderHotkey:enable)
end
end)
--finderHotkey:enable()
hs.window.filter.new('Citrix Viewer')
:subscribe(hs.window.filter.windowFocused,function() finderHotkey:disable() end)
:subscribe(hs.window.filter.windowUnfocused,function() finderHotkey:enable() end)
Any of you who are comfortable building your own Hammerspoon build, please take a look at #2483.
I was able to successfully run the example given above and restart without a crash, but I don't regularly use
hs.window.filter
or anything that does, so I really don't know what to do to test further.If you can test this out, please let me know your results. I'll see if I can come up with some other tests on my own as well.
Fix my issue.
I used hs.window.filter to set input method on switch to application:
-- set input methods [[[2
local function Chinese()
-- hs.keycodes.setMethod("Pinyin - Simplified")
-- hs.keycodes.currentSourceID("com.googlecode.rimeime.inputmethod.Squirrel.Rime")
hs.keycodes.currentSourceID("com.baidu.inputmethod.BaiduIM.pinyin")
end
local function English()
-- hs.keycodes.setLayout("U.S.")
-- hs.keycodes.currentSourceID("com.apple.keylayout.US")
hs.keycodes.currentSourceID("com.apple.keylayout.USExtended")
end
local function set_app_input_method(app_name, set_input_method_function, event)
event = event or hs.window.filter.windowFocused
wf = hs.window.filter.new(app_name)
wf:subscribe(
event,
function()
set_input_method_function()
end
)
end
set_app_input_method("Hammerspoon", English, hs.window.filter.windowCreated)
set_app_input_method("Alfred", English, hs.window.filter.windowCreated)
If you can test this out, please let me know your results.
works!
This should be fixed in 0.9.80 which has just been released.
Running the test script below gives an error.
Output:
Edit: this is on Big Sur