mjolnirapp / mjolnir

Lightweight automation and productivity app for OS X
5.2k stars 128 forks source link

Mjolnir sometimes crashes on input source change #532

Closed trishume closed 4 years ago

trishume commented 10 years ago

The code that detects input source changes has something fishy going on, sometimes it works, sometimes it crashes on change and sometimes it doesn't detect the change.

I'm using OSX Yosemite with Mjolnir 0.4.3 with this config file https://github.com/trishume/dotfiles/blob/master/mjolnir/mjolnir.symlink/init.lua

Here's the crash log I get when it crashes: http://pastebin.com/epb2LVMX

thesoftwarephilosopher commented 10 years ago

@trishume Can you list the modules you're using?

trishume commented 10 years ago

They're in the config I linked, problem is likely in the keycodes module.

cmsj commented 9 years ago

We've been seeing this in Hammerspoon too. I don't have a solid fix yet, but my current hypothesis is that it's a threading issue - AFAICT, NSNotificationCenter callbacks happen on threads, and are not guaranteed to happen on the main thread where Lua is. I'm experimenting with wrapping the callbacks with a performSelectorOnMainThread call, but I don't have concrete results yet.

cmsj commented 9 years ago

(FWIW, moving the selectors to do their work on the main thread has fixed this and other crashes, in Hammerspoon)

cmsj commented 9 years ago

Actually that wasn't the only input source change related crash. It also seems that the garbage collection method isn't getting called on keycodes meta objects, leaking an observer. After the reload, the leaked observer still fires, and things explode when Lua starts digging for the handler. (Edit: I have a candidate patch for that in Hammerspoon, but I'm not yet 100% sure that I got it right: https://github.com/Hammerspoon/hammerspoon/pull/190 )

knyar commented 9 years ago

I've seen both Mjolnir and pre-0.9.19 Hammerspoon crash like this multiple times a day. However, I have been running Hammerspoon 0.9.19 for several days now and have not seen it crash, so it seems that the issue has been fixed. You might want to cherry-pick the changes (which I guess are https://github.com/Hammerspoon/hammerspoon/commit/7a187f5f558cba5f83f2dc02135181b5db44210c and https://github.com/Hammerspoon/hammerspoon/commit/b55455617724181c1391eca70d8d1d0c1b81de21) back to Mjolnir.

Thanks a lot, @cmsj, great job!

github-actions[bot] commented 4 years ago

Stale issue message