Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update iohook and Electron versions #13

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ferothefox
Copy link

@ferothefox ferothefox commented Jul 20, 2023

Hi, I work on MechaKeys, which is similar to MechvibesPlusPlus, and it looks like you use iohook as your core library for mouse and keyboard detection. Your app currently uses the wilix-team iohook library, which has been abandoned and is unmaintained. This is a security risk for you and your users, who are using a version of Electron that's four years old by now.

We realize the security risk is too great for apps that are built entirely around tracking keyboard and mice activity, so we have an open-source and maintained version of iohook at our company repo: https://github.com/robolab-io/iohook, which supports Electron >=22 and Node 18. We're progressively notifying other projects that use an outdated iohook to switch as soon as possible. You can check the Actions tab to see our CI pipelines in action.

I began some work on migrating your app to work with Electron's new standards and security practices, as a lot of methods have been deprecated or reworked. In particular I had to add a patch to our fork in order to support using iohook in the preloader/renderer process. Native modules that aren't context-aware (like the current version of iohook) aren't supported past Electron 14, see Electron's reasoning: electron/electron#18397. Additionally, some changes regarding sandboxing means that it's impossible to use remote.getGlobal in the preload process. Doing so always returns undefined. To mitigate this, I attempted to replace globals with IPC. Unfortunately this is more trouble than it's worth - you'd need to rearchitect your entire app as putting all of the functionality in preload is incredibly insecure and ripe for issues.

This PR is unfinished (and will likely stay unfinished, depending on my schedule), but here's a rundown of the timeline to bring a better, faster, and more secure experience to your users.

Suggested Timeline

Core fixes

  • Migrate from @wilix-team/iohook to @mechakeys/iohook
  • Upgrade Electron to version 25, which takes advantage of all of its latest security fixes, performance enhancements, and new features

Performance, footprint

@NotLazy
Copy link

NotLazy commented Dec 24, 2023

I'd like to ask you a couple things. I'm the current, active maintainer of the original Mechvibes.

Firstly, how would you recommend handling audio if we were to update electron? howler only works in the renderer process, and better alternatives don't exist for handling audio in main.js especially cross platform. My search for alternatives essentially yielded tools which use other programs under the hood, such as Windows Media Player or afplay. My concern with keeping it in a browser window would be potentially added latency for ipc to communicate. Testing would be needed to judge and measure the exact effects.

Secondly, you recommend vuejs while telling us to remove jquery due to size reasons, but according to your source, jquery adds 85.1kb (which, mechvibes' only weighs in at 69.4kb according to github) while vuejs adds 98.8kb. React definitely could be a solution here, coming in at only 6.4kb but react has a much steeper learning curve than jquery, and I'd suspect react would result in larger source code files in comparison, which might outweigh the results of switching to react.

Edit: So I went ahead and tested the delay implications of using ipc to transmit to browser window. At worst I saw a 0.29s delay, and at best I saw a 0.001s delay. This test was conducted manually without updating electron and without updating iohook, using the Date built-in to measure the difference between the seconds and milliseconds immediately when the keydown event is fired by iohook and then again immediately when the ipc event is received by the browser window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants