You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It works great except for one condition when it is used together with Electron (v21.0.0 tested). On macOS, if the user has not granted the application the Accessibility permission then the application crashes when you call uIOhook.start().
If you run the application from the terminal then it is the terminal app's permission that takes effect. So if you've already given it accessibility permissions then you may have to revoke that in System Preferences -> Security & Privacy to trigger the crash.
Before the crash this is printed:
hook_run [1407]: Accessibility API is disabled!
The prompt to grant accessibility permissions is shown as expected (see screenshot below), followed immediately by the crash. When run through Electron Fiddle the macOS crash reporter isn't shown.
Not a fix but a workaround would be to use Electron's systemPreferences.isTrustedAccessibilityClient() to have more control over showing the dialog, and then only do require("uiohook-napi") once you know the permissions are already granted. This approach has other advantages too since it lets you warn the user with a custom message before seeing the scary ambiguously-worded dialog, and also avoids the occasional issue of needing to restart the app before the perms take effect.
Hello, thanks for the package.
It works great except for one condition when it is used together with Electron (v21.0.0 tested). On macOS, if the user has not granted the application the Accessibility permission then the application crashes when you call
uIOhook.start()
.I created an Electron Fiddle to make it easy for you to reproduce: https://gist.github.com/stefansundin/937b9b20b28d58bc4d3ff05157d412c5
I included the full crash log in the gist above (scroll to the bottom), but here's the important part:
If you run the application from the terminal then it is the terminal app's permission that takes effect. So if you've already given it accessibility permissions then you may have to revoke that in System Preferences -> Security & Privacy to trigger the crash.
Before the crash this is printed:
The prompt to grant accessibility permissions is shown as expected (see screenshot below), followed immediately by the crash. When run through Electron Fiddle the macOS crash reporter isn't shown.
The crash is happening on this line:
uiohook-napi/src/lib/uiohook_worker.c
Line 179 in 63745a5
I tried commenting that out and it prevents the crash, but of course there may be a memory leak created in that case.
Would love to hear if you have any ideas on how to safely address this problem. Thank you!
Versions: uiohook-napi v1.5.0, Electron v21.0.0, node.js v16.17.0
The text was updated successfully, but these errors were encountered: