Closed hsource closed 6 months ago
Proposed changes will cause errors to be silently ignored. I'm actually confused why this happens, env is in napi_pending_exception state but when flow returns to js it's gone.
Test snippet:
const { uIOhook } = require('./dist')
uIOhook.on('mousemove', (e) => {
console.log(`moved ${e.x} ${e.y}`)
uIOhook.emit('error', new Error('test'))
})
uIOhook.start()
I'm also seeing this CGEventTap timeout!
crash occur intermittently when synchronous/modal system dialogs are in use while uiohook-napi is running in Electron/Mac. Seems like it happens if a synchronous dialog is shown via dialog.showMessageBoxSync()
and keyboard keys are pressed while the dialog is up. Doesn't happen totally consistently but the likelihood of it crashing seems to increase the longer the dialog remains onscreen. I'm able to mostly avoid it by making sure to call uIOhook.stop()
just before spawning any sync dialog but still get the crash sometimes.
Still encountering the CGEventTap timeout!
crash in an Electron app on macOS sometimes, especially on older/slower Intel Macs. Tends to happen when my Electron app is backgrounded and some intensive app is in the foreground with heavy cpu use. The result is that my app keeps running but the uiohook process stops working, and it's a real showstopper because AFAICT it's impossible for my app to detect when it enters this state, but then once it's in this state any call to uIOhook.stop()
crashes the entire app.
@hsource I know this thread is old and this might have left your headspace long ago, but I was wondering what your fix here actually does on the CGEventTap timeout!
event. I see that your changes prevent a crash but also seems to prevent the input listening process from restarting, is that correct? Seems like you were trying to simply avoid a crash on quitting, but the side effect is that if we're not quitting, the hook becomes disabled. If the CGEventTap timeout!
occurs during normal use and not when quitting as in the case I described above, then uIOhook
would have to be stopped and restarted (from JS) in order to regain key input listening?
I wonder if this recent commit to libuiohook 1.2 that changes memory allocation handling in create_event_runloop_info()
and destroy_event_runloop_info()
would help with this issue https://github.com/kwhat/libuiohook/pull/166
Sorry, I haven't touched this library in a while and don't think I'll have time to look into it more deeply. I'm not sure if it's related, and never really found the root cause. Your hint does seem possible!
My guess is that there's some race condition or a thrown error in native code that makes it get stuck. I haven't looked into it more deeply though.
Thanks for the reply @hsource, understood. If I get a chance I will try building uiohook-napi using latest libuiohook 1.2 and see if that change made a difference. Hopefully the next release of uiohook-napi will incorporate the change anyway. It's really hard to test for this issue as it's hard to trigger the conditions that lead to CGEventTap timeout!
consistently.
I am also often troubled by this problem. The program stops working properly after a while. I hope this issue will be resolved soon.😵💫
I am also often troubled by this problem. The program stops working properly after a while. I hope this issue will be resolved soon.😵💫
Have this issue fixed, im facing this issue my app goes in not responding state in mac.
I noticed the recent release of uiohook-napi (v1.5.1) incorporates the above-mentioned fix in libuiohook (thanks @SnosMe!) but I haven't tested it on Mac yet. @mushan0x0 @komSh I wonder if you're still seeing this issue even in latest v1.5.1?
I noticed the recent release of uiohook-napi (v1.5.1) incorporates the above-mentioned fix in libuiohook (thanks @SnosMe!) but I haven't tested it on Mac yet. @mushan0x0 @komSh I wonder if you're still seeing this issue even in latest v1.5.1?
Thank you for your efforts. After testing, the issue still exists in v1.5.1.
Confirming that I also still get the occasional CGEventTap timeout!
error in v1.5.1 which leads to silent failure of the hook and eventually crashes. Still really hard to trigger it though, tough to debug. Will try to investigate further when I have the time.
same question,When running on a mac for a while exit software will not respond
The CGEventTap timeout error is fixed by #37 or https://github.com/kwhat/libuiohook/pull/184
This does not fix that issue, so I'll close this.
Motivation
Crashes
While testing awakened-poe-trade on Mac, I noticed that quitting Awakened POE Trade would cause a crash instead of exiting gracefully.
To reproduce:
yarn electron:serve
in awakened-poe-tradeIt'll give a stacktrace like this and an unexpected closing error:
Hang when exiting
Sometimes, when I close Awakened POE Trade via the dock, it fails to exit. It seems to do this only after the error message:
Fix
Testing
yarn prebuild
on local versionyarn add ../uiohook-napi
to install local version