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

Loosing left Click >> Hammerspoon Error : attempt to index a nil value (field 'indicator') #41

Closed
NylonDiamond opened this issue Sep 22, 2020 · 11 comments · Fixed by #59
Assignees
Labels
bug Something isn't working

Comments

@NylonDiamond
Copy link

I get the error below after a while. I lose the ability to left click my mouse. Right click works fine as well as everything else. Weird. Any ideas?

stack traceback: .../jesseskelton/.hammerspoon/stackline/stackline/stack.lua:73: in local 'fn' ...on.app/Contents/Resources/extensions/hs/fnutils/init.lua:130: in function 'stackline.lib.utils.filter' .../jesseskelton/.hammerspoon/stackline/stackline/stack.lua:72: in function 'stackline.stackline.stack.getWindowByPoint' ...kelton/.hammerspoon/stackline/stackline/stackmanager.lua:118: in function 'stackline.stackline.stackmanager.getClickedWindow' ...seskelton/.hammerspoon/stackline/stackline/stackline.lua:26: in function <...seskelton/.hammerspoon/stackline/stackline/stackline.lua:22> 2020-09-21 21:47:06: 21:47:06 ERROR: LuaSkin: hs.eventtap callback error: .../jesseskelton/.hammerspoon/stackline/stackline/stack.lua:73: attempt to index a nil value (field 'indicator')

@AdamWagner
Copy link
Owner

AdamWagner commented Sep 22, 2020

I've also experienced this, and can only agree: "Weird".

My unsatisfying short-term strategy has been to reload hammerspoon (which I have bound to cmd+alt+r :/

hs.hotkey.bind({'cmd', 'alt'}, 'r', hs.reload)

I always have stackline running, and run into this maybe… once a week?

Thanks for documenting this so we can fix it.

A slightly better (but still pretty random) guess: There's a race condition somewhere; If the indicator isn't rendered before hs.eventtap.new() is called, then we get the error above and and hammerspoon swallows all left clicks.

Question for you @NylonDiamond: do you actually use/want the ability the click indicators? I ask because I've been thinking about configuration options, and if you don't want this feature, it'd be nice if you could turn it off and avoid the rough edges.

@AdamWagner AdamWagner added the bug Something isn't working label Sep 22, 2020
@NylonDiamond
Copy link
Author

NylonDiamond commented Sep 22, 2020

I have to reload a few times per day, unfortunately. I'd be down for toggling the ability to click indicators. I don't use it anyways.

@NylonDiamond
Copy link
Author

Did we decide to add the remove or toggle the click indicators functionality? I get this issue like 10x every day. I can't really use Stackline at the moment.

@AdamWagner
Copy link
Owner

Sorry to hear that @NylonDiamond .

Good news tho – yes – I made good progress on better configurability this weekend, and there's a feature flag to enable / disable clickToFocus:

You can toggle set it off in your init.lua file after calling stackline:init()

stackline.config:set('features.clickToFocus', true)

…or turn it off via the command line using the ipc interface:

echo ":features.clickToFocus:false` | hs -m stackline-config

I described the changes in more detail here: #33 (comment)

All of these changes are very very fresh (you'd probably be the first to try it). I understand if you're not interested in doing more QA here :-)

I can let you know when it's merged in, tho!

https://github.com/AdamWagner/stackline/tree/feature/configuration

@alextremblay
Copy link

I've also experienced this issue.

I don't know if it helps your investigation to know this, but i find that i can regain left-click ability without reloading hammerspoon just by switching to a different space and back.

i dunno, maybe that'll give you some idea of the root cause?

@AdamWagner
Copy link
Owner

Thanks @alextremblay ! That does give me a better idea of the root cause… or at least it narrows the scope of the hunt for the root cause ;-)

@AdamWagner
Copy link
Owner

@NylonDiamond just merged in improved configuration updates. Note that, in the new version, Stackline must be initialized in your ~/.hammerspoon/init.lua` file.

init.lua before

stackline = require "stackline.stackline.stackline"

init.lua after

stackline = require "stackline.stackline.stackline"
stackline:init() -- must initialize stackline in your init.lua file!

The changes, of course, allow you to pass in custom config options ;-)

stackline = require "stackline.stackline.stackline"

local myStackline = {
    appearance = { 
      showIcons = false,       -- default is true
    },
    features = {
        clickToFocus = false,  -- default is true
        fzyFrameDetect = {
            fuzzFactor = 25    -- default is 30
        },
    },
}

stackline:init(myStackline)  -- ah yea!          

@alextremblay
Copy link

Much like @NylonDiamond, I've noticed the following in the logs when I lose left-click:

stack traceback:
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:73: in local 'fn'
	...on.app/Contents/Resources/extensions/hs/fnutils/init.lua:130: in function 'stackline.lib.utils.filter'
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:72: in function 'stackline.stackline.stack.getWindowByPoint'
	...s/alex/.hammerspoon/stackline/stackline/stackmanager.lua:115: in function 'stackline.stackline.stackmanager.getClickedWindow'
	/Users/alex/.hammerspoon/stackline/stackline/stackline.lua:49: in function </Users/alex/.hammerspoon/stackline/stackline/stackline.lua:47>
2020-10-16 08:28:05: 08:28:05 ERROR:   LuaSkin: hs.eventtap callback error: /Users/alex/.hammerspoon/stackline/stackline/stack.lua:73: attempt to index a nil value (field 'indicator')
stack traceback:
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:73: in local 'fn'
	...on.app/Contents/Resources/extensions/hs/fnutils/init.lua:130: in function 'stackline.lib.utils.filter'
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:72: in function 'stackline.stackline.stack.getWindowByPoint'
	...s/alex/.hammerspoon/stackline/stackline/stackmanager.lua:115: in function 'stackline.stackline.stackmanager.getClickedWindow'
	/Users/alex/.hammerspoon/stackline/stackline/stackline.lua:49: in function </Users/alex/.hammerspoon/stackline/stackline/stackline.lua:47>
2020-10-16 08:28:09: 08:28:09 ERROR:   LuaSkin: hs.eventtap callback error: /Users/alex/.hammerspoon/stackline/stackline/stack.lua:73: attempt to index a nil value (field 'indicator')
stack traceback:
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:73: in local 'fn'
	...on.app/Contents/Resources/extensions/hs/fnutils/init.lua:130: in function 'stackline.lib.utils.filter'
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:72: in function 'stackline.stackline.stack.getWindowByPoint'
	...s/alex/.hammerspoon/stackline/stackline/stackmanager.lua:115: in function 'stackline.stackline.stackmanager.getClickedWindow'
	/Users/alex/.hammerspoon/stackline/stackline/stackline.lua:49: in function </Users/alex/.hammerspoon/stackline/stackline/stackline.lua:47>

Interestingly, when i switch to a different space and back, I get this in the logs:

2020-10-16 08:28:14: 08:28:14 ERROR:   LuaSkin: hs.application.watcher callback: /Users/alex/.hammerspoon/stackline/stackline/window.lua:63: attempt to perform arithmetic on a nil value (field 'stackIdx')
stack traceback:
	/Users/alex/.hammerspoon/stackline/stackline/window.lua:63: in function 'stackline.stackline.window.setupIndicator'
	/Users/alex/.hammerspoon/stackline/stackline/window.lua:173: in function 'stackline.stackline.window.redrawIndicator'
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:60: in local 'fn'
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:33: in function 'stackline.stackline.stack.eachWin'
	/Users/alex/.hammerspoon/stackline/stackline/stack.lua:58: in function 'stackline.stackline.stack.redrawAllIndicators'
	/Users/alex/.hammerspoon/stackline/stackline/window.lua:147: in function 'stackline.stackline.window.redrawIndicator'
	/Users/alex/.hammerspoon/stackline/stackline/stackline.lua:114: in function 'stackline.stackline.stackline.redrawWinIndicator'
	...n.app/Contents/Resources/extensions/hs/window/filter.lua:944: in upvalue 'emit'
	...n.app/Contents/Resources/extensions/hs/window/filter.lua:970: in method 'filterEmitEvent'
	...n.app/Contents/Resources/extensions/hs/window/filter.lua:1004: in method 'emitEvent'
	...n.app/Contents/Resources/extensions/hs/window/filter.lua:1096: in method 'unfocused'
	...n.app/Contents/Resources/extensions/hs/window/filter.lua:1285: in method 'deactivated'
	...n.app/Contents/Resources/extensions/hs/window/filter.lua:1270: in function <...n.app/Contents/Resources/extensions/hs/window/filter.lua:1267>
	(...tail calls...)
2020-10-16 08:28:14: num windows changed

and then left click is restored

Also interestingly, this 'trick' only works if i switch spaces on the display that had the active, focused window when the problem started. i guess it has something to do with unloading or unfocusing the focused window or something?

@AdamWagner AdamWagner added the workaround available Issue is addressed, but is left open to help others label Nov 7, 2020
@AdamWagner AdamWagner self-assigned this Nov 7, 2020
@AdamWagner
Copy link
Owner

@alextremblay While investigating #46, I found a reliable way to "lose left click": re-initialize stackline while it's already running.

Especially since the location of stackline:init() changed several times in the last couple of releases, I wonder if this may be a factor.

You could either pull the version in this branch: https://github.com/AdamWagner/stackline/tree/fix/nil-windows-in-get-summary or add the following snippet to /stackline/stackline.lua at the top of init():

if stackline.manager then
    -- guard against re-initializtion https://github.com/AdamWagner/stackline/issues/46#issuecomment-723527826
    return print('stackline already initialized')
end

@AdamWagner AdamWagner added potentially-fixed A potential fix has been posted, but needs external verification before being merged. and removed workaround available Issue is addressed, but is left open to help others labels Nov 29, 2020
@alextremblay
Copy link

Thank you @AdamWagner

I implemented the guard condition, and haven't experienced the issue since.

i think you can close this issue?

@AdamWagner
Copy link
Owner

Great to hear @alextremblay. I merged the guard to master, and will close this now.

@AdamWagner AdamWagner linked a pull request Dec 12, 2020 that will close this issue
@AdamWagner AdamWagner removed the potentially-fixed A potential fix has been posted, but needs external verification before being merged. label Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants