Skip to content

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

Closed

Description

@NylonDiamond

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')

Activity

  1. AdamWagner commented on Sep 22, 2020

    @AdamWagner
    Owner

    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.

  2. added
    bug
    on Sep 22, 2020
  3. NylonDiamond commented on Sep 22, 2020

    @NylonDiamond
    Author

    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.

  4. NylonDiamond commented on Oct 4, 2020

    @NylonDiamond
    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.

  5. AdamWagner commented on Oct 4, 2020

    @AdamWagner
    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

  6. alextremblay commented on Oct 6, 2020

    @alextremblay

    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?

  7. AdamWagner commented on Oct 10, 2020

    @AdamWagner
    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 ;-)

  8. AdamWagner commented on Oct 10, 2020

    @AdamWagner
    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!          
  9. alextremblay commented on Oct 16, 2020

    @alextremblay

    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?

  10. added
    workaround available
    on Nov 7, 2020
  11. self-assigned this
    on Nov 7, 2020
  12. AdamWagner commented on Nov 28, 2020

    @AdamWagner
    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
  13. added
    potentially-fixed
    and removed
    workaround available
    on Nov 29, 2020
  14. alextremblay commented on Dec 8, 2020

    @alextremblay

    Thank you @AdamWagner

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

    i think you can close this issue?

  15. AdamWagner commented on Dec 12, 2020

    @AdamWagner
    Owner

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

  16. linked a pull request that will close this issueFix/nil windows in get summary #59on Dec 12, 2020
  17. removed
    potentially-fixed
    on Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions