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

Freezes when more than one app use iohook #93

Closed
JasminDreasond opened this issue Jul 3, 2018 · 22 comments · Fixed by #294
Closed

Freezes when more than one app use iohook #93

JasminDreasond opened this issue Jul 3, 2018 · 22 comments · Fixed by #294
Labels
bug An identified bug, though not necessarily being currently investigated help Actively soliciting contributions to help complete this work

Comments

@JasminDreasond
Copy link

JasminDreasond commented Jul 3, 2018

Current Behavior

whenever I open more than one electron application using iohook, it makes the whole operating system freeze for a few seconds.

Steps to Reproduce (for bugs)

  1. Open a Electron application with the the ioHook module.
  2. Open a second Electron application with the ioHook module.
  3. The second Electron application will freeze when the app start loading.

Context

I want to use the module in more than one project, but I do not want this type of problem to happen.

Your Environment

  • Version used: 0.2.0
  • Nodejs 8.9.3
  • Electron 2.0.2
  • Windows 10
@JasminDreasond JasminDreasond changed the title Freezing Windows 10 Freezing on Windows 10 Jul 4, 2018
@Djiit Djiit added the bug An identified bug, though not necessarily being currently investigated label Jul 4, 2018
@serafimpinto
Copy link

Same here! 😞

@jlsilva1994
Copy link

jlsilva1994 commented Jul 12, 2018

Same here too!
A temporary fix for the Electron apps, if you DON'T want to open a second one, you can use this code only have one app opened, and when you try to open a second one, it redirects you to first one you have open:

const shouldQuit = app.makeSingleInstance(() => {
// do your code to redirect to the window here!
})
if (shouldQuit) {
app.exit() // could use app.quit(), but exit is more fast and prevent other errors
}

@JasminDreasond
Copy link
Author

JasminDreasond commented Jul 15, 2018

sorry, but my problem is not two electron applications repeated. My problem is two or more different electron applications

@Djiit
Copy link
Collaborator

Djiit commented Jul 16, 2018

What you could do is, e.g. write a file somewhere in the user folder and check if it is present before launching the app.

@JasminDreasond
Copy link
Author

@Djiit
I am confused. Can you explain better please? :c
the simple fact of the var ioHook = require('iohook'); exists, makes everything freeze

@MiguelSmith
Copy link

I am getting the same problem with two nodejs applications, where if the first one has an ioHook module loaded, the second one that opens with an ioHook module loaded lags a lot and causes the cursor and other IO inputs to lag out until the second application is closed.

@Djiit
Copy link
Collaborator

Djiit commented Oct 29, 2018

I got it now. Maybe we could tell iohook to only listen once system-wide, and provide a way for users to know it (like triggering an event "IOHookAlreadyListening". Any C++ programmer here ?

@Djiit Djiit added the help Actively soliciting contributions to help complete this work label Oct 29, 2018
@Djiit Djiit changed the title Freezing on Windows 10 Freezes when more than one app use iohook Oct 29, 2018
@rscord
Copy link

rscord commented Feb 13, 2019

When launching two or more processes with iohook module, my mouse moves like in slow-mo. This is actually a big problem. Imagine if user launches two or more completely different apps that uses iohook module.

Test code:

const {exec} = require('child_process');
const iohook = require('iohook');

iohook.start();

if (process.argv.length === 2) {
	console.log('Launched main');
	iohook.on('keydown', (e) => {
		console.log('Main', e.rawcode);
	});
	exec([`"${process.argv[0]}"`, process.argv[1], '-t'].join(' ')).stdout.pipe(process.stdout);
} else {
	console.log('Launched child');
	iohook.on('keydown', (e) => {
		console.log('Child', e.rawcode);
	});
}

Luke265 added a commit to Luke265/iohook that referenced this issue Feb 13, 2019
I am not a c++ programmer, and I am not sure what I did here. But this fixes issue wilix-team#93.
@Lennon925
Copy link

@Djiit , this issue hasn't been resolved by now? I have to give up iohook because of this issue.

@Suhail
Copy link

Suhail commented Jul 9, 2019

This issue: #176 seems related to this one. Similar mouse slo-mo problem.

@Wizek
Copy link
Contributor

Wizek commented Sep 2, 2019

This freezing issue is still present. @Djiit, why did you close #145? Did that not solve this problem? Or was something else wrong with that PR?

Also, does anyone know of an alternative package for Node.js that does not suffer from this bug?

@Wizek
Copy link
Contributor

Wizek commented Sep 3, 2019

@Lennon925 Did you find an alternative for iohook?

@Lennon925
Copy link

Lennon925 commented Sep 5, 2019

@Lennon925 Did you find an alternative for iohook?

Acturally not yet. But I am using "robotjs" which can monitor mouse event only.

@Wizek
Copy link
Contributor

Wizek commented May 9, 2020

As this is still not fixed, I'm switching over to something that seems to work much better:

https://www.npmjs.com/package/gkm

@emptycrown
Copy link

Hey, we just ran into this exact issue (wasn't aware that it was caused by iohook but luckily ran into this thread).

Is there any way to simply detect if there's another instance of iohook and shut down iohook functionality in our app?

@Wizek
Copy link
Contributor

Wizek commented May 23, 2020

I'm not aware of that, but I strongly advise against using iohook in any way before this issue is fixed somewhere. Gkm it turns out has quite some issues too. Next I'll look into if I can use Electron.js to be able to respond to global keys.

@emptycrown
Copy link

Got it, yeah we've come to the same conclusion but unfortunately, we haven't found a good alternative. We've experimented with the globalShortcut that comes with Electron.js, but we'd rather have it listen to a key-binding rather than actually register a shortcut, which can conflict with other shortcuts on the machine. For example, the user is playing a game or something, the shortcuts will be blocked.

@Wizek
Copy link
Contributor

Wizek commented May 25, 2020

Is that so? That's strange. I've still yet to experiment with the Electron approach, would be a shame if they couldn't react to a shortcut key that another app is also listening to. Have you perhaps a small reproducible experimental example that I could also try to replicate this? Because if so, their project might be much more active, receptive and interested in fixing this shortcoming of theirs, and we could share it with them too while raising an issue with them.

@JoeBernardi
Copy link

It looks like libuiohook has fixed this issue upstream somewhat recently: kwhat/libuiohook#72

I've yet to try dropping this newer libuiohook version in, but it certainly feels promising.

@chipimix
Copy link

chipimix commented Jul 13, 2020

Hello! I'm also experiencing this abnormal behavior! :(
Its really easy to replicate, just run two electron apps which use iohook [eg Loom , Cortex or lowkey.gg] and everything freezes.
Is there any fix on this incoming soon due to the recent libuiohook changes?
Thanks!

@chevonc
Copy link
Contributor

chevonc commented Feb 10, 2021

Put out a PR for a fix for this. Welcoming reviews here: #294

@michelvermeulen
Copy link

Following. I have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An identified bug, though not necessarily being currently investigated help Actively soliciting contributions to help complete this work
Projects
None yet
Development

Successfully merging a pull request may close this issue.