wilix-team / iohook

Node.js global keyboard and mouse listener.
https://wilix-team.github.io/iohook
MIT License
1.2k stars 291 forks source link

fix: 'non-context-aware' error for Electron #387

Open xiewh7 opened 2 years ago

xiewh7 commented 2 years ago

fix: 'non-context-aware' error for Electron

Description

The latest releases of Electron prevent "non-context-aware" native modules. By Replacing NODE_MODULE with NAN_MODULE_WORKER_ENABLED this fixes the errors for Electron.

marcelblum commented 2 years ago

The problem is lack of cleanup, doing location.reload() or advancing to any different html page crashes, and doing iohook.unload() often crashes.

marcelblum commented 2 years ago

You can see my experiments towards this end at https://github.com/marcelblum/iohook but I didn't get very far and ended up needing to use Electron pre-v14 anyway.

xiewh7 commented 2 years ago

@marcelblum But we need to use Electron V16. How can we fix this problem in Electron after-v14?

marcelblum commented 2 years ago

I'm not sure, I probably don't have the c++ expertise to solve this, but like I said you can see what progress I made towards it in my fork. If you don't ever need to do a reload() or load a different html page in the same renderer BrowserWindow then the problem can probably be ignored...

sonukapoor commented 1 year ago

@WilixLead / @Djiit Can you help with the above PR? I am not familiar with C++, to help out. It would be great though if we can get this working again. Electron is currently at version 21.

lacymorrow commented 10 months ago

Hi is this still a relevant change? We can merge it if so.