Code Monkey home page Code Monkey logo

Comments (17)

matthewshirley avatar matthewshirley commented on August 20, 2024 4

Thanks for raising this issue.

I'll work on implementing this into the project. You could probably work around the issue by putting this snippet into your project.

process.on('exit', () => {
  iohook.unload();
});

from iohook.

jlsilva1994 avatar jlsilva1994 commented on August 20, 2024 3

Hello guys, I was digging on the issues and code of https://github.com/kwhat/libuiohook and tring to fix another bug I have in my application and found a solution.

He had fixed some errors on related to the latest versions of macOS on this commit:

kwhat/libuiohook@28c9926

Then I created a manual build to iohook with this version of libuiohook (branch 1.1) and now the app closes with no crash log.

from iohook.

matthewshirley avatar matthewshirley commented on August 20, 2024 1

@towerofnix i'll try to find a solution for linux on the weekend. 👍

from iohook.

Djiit avatar Djiit commented on August 20, 2024 1

Hi there, could you try to reproduce the error with the current iohook version ? We have updated the libuiohook since and I think it should be fixed.

from iohook.

towerofnix avatar towerofnix commented on August 20, 2024

@matthewshirley That looks like it actually hangs node altogether:

$ node
> h = require('iohook')
> process.on('exit', () => { h.unload() }) 
> process.exit(0)

And then it hangs, doing nothing until I press ^C, which force-kills node.

from iohook.

damianobarbati avatar damianobarbati commented on August 20, 2024

@matthewshirley same problem on High Sierra, I got "quit unexpectedly" but you exit handler did work for it.

from iohook.

DCzajkowski avatar DCzajkowski commented on August 20, 2024

I had issues with exitting too, but currently I am using this approach (this is some pseudo-code to show off the idea):

// KeyboardEventsHandler.js

export default class KeyboardEventsHandler {
    constructor(handler) {
        this.handler = handler
        this.handler.on('keydown', this._onKeyDown)

        this.handler.start()
    }

    destructor() {
        this.handler.unload()
        this.handler.stop()
    }

    _onKeyDown({ keycode }) {
        console.log(keycode)
    }
}

// index.js

import ioHook from 'iohook'
import KeyboardEventsHandler from './KeyboardEventsHandler'

const keh = new KeyboardEventsHandler(ioHook)

// This is Electron specific:
app.on('before-quit', () => {
    keh.destructor()
})

Hopefully it works for you :)

from iohook.

jlsilva1994 avatar jlsilva1994 commented on August 20, 2024

hi @DCzajkowski, i have the same problem on electron and i tried your solution.
i call the unload() method on iohook, in the app.on('before-quit'), the app quits, but the iohook put out this crash log:

PID 38596 received SIGSEGV for address: 0x0
0   segfault-handler.node               0x000000010c1ae408 _ZL16segfault_handleriP9__siginfoPv + 312
1   libsystem_platform.dylib            0x00007fff6b15af5a _sigtramp + 26
2   ???                                 0x0000000000000000 0x0 + 0
3   libnode.dylib                       0x000000010b33bf1c _ZN2v88internal14LookupIterator31PrepareTransitionToDataPropertyENS0_6HandleINS0_8JSObjectEEENS2_INS0_6ObjectEEENS0_18PropertyAttributesENS5_14StoreFromKeyedE + 156
4   libnode.dylib                       0x000000010b402f31 _ZN2v88internal10HeapNumber15HeapNumberPrintERNSt3__113basic_ostreamIcNS2_11char_traitsIcEEEE + 26945
5   libnode.dylib                       0x000000010b53dac7 _ZNK2v88internal21RegisterConfiguration10AreAliasesENS0_21MachineRepresentationEiS2_i + 453383
6   libnode.dylib                       0x000000010af5a245 _ZN2v86Object3SetENS_5LocalINS_7ContextEEENS1_INS_5ValueEEES5_ + 213
7   Electron Framework                  0x00000001062ab65a _ZN4base8internal9BindStateIPFN2v85LocalINS2_5ValueEEEPNS2_7IsolateENS3_INS2_6StringEEEPN4mate9ArgumentsEEJEE7DestroyEPKNS0_13BindStateBaseE + 474
8   Electron Framework                  0x00000001061fc27b _ZN4mate8internal17CreateCustomEventEPN2v87IsolateENS1_5LocalINS1_6ObjectEEES6_ + 107
9   Electron Framework                  0x00000001061c4b88 _ZN4base12DeleteHelperIN4atom8TrayIconEE8DoDeleteEPKv + 2408
10  Electron Framework                  0x00000001061c2f68 _ZN4atom3api4Tray14OnMouseEnteredERKN3gfx5PointEi + 136
11  Electron Framework                  0x00000001061c2fd0 _ZN4atom3api4Tray13OnMouseExitedERKN3gfx5PointEi + 64
12  Electron Framework                  0x00000001061c2fed _ZThn64_N4atom3api4Tray13OnMouseExitedERKN3gfx5PointEi + 13
13  Electron Framework                  0x00000001062517a7 _ZN4atom8TrayIcon17NotifyMouseExitedERKN3gfx5PointEi + 119
14  Electron Framework                  0x0000000106252d59 _ZN4atom8TrayIcon15NotifyDragEndedEv + 5001
15  AppKit                              0x00007fff40282eb7 -[NSTrackingArea _dispatchMouseExited:] + 86
16  AppKit                              0x00007fff40282db2 -[NSTrackingArea _mouseExited:] + 78
17  AppKit                              0x00007fff4086646f -[NSApplication(NSEvent) sendEvent:] + 3031
18  Electron Framework                  0x000000010621833b _ZN4base8internal9BindStateIMN4atom12LoginHandlerEFvvEJ13scoped_refptrIS3_EEE7DestroyEPKNS0_13BindStateBaseE + 379
19  AppKit                              0x00007fff400c68b5 -[NSApplication run] + 812
20  Electron Framework                  0x00000001063efb0e _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 820718
21  Electron Framework                  0x00000001063ee50c _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 815084
22  Electron Framework                  0x0000000106404a63 _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 906563
23  Electron Framework                  0x0000000106670eef _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 3447247
24  Electron Framework                  0x0000000106670d10 _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 3446768
25  Electron Framework                  0x0000000106673392 _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 3456626
26  Electron Framework                  0x000000010666cd6c _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 3430476
27  Electron Framework                  0x00000001065b5f40 _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 2681376
28  Electron Framework                  0x00000001081ab3d4 _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 31997620
29  Electron Framework                  0x00000001065b4d54 _ZNK8crashpad8internal15ScopedDIRCloserclEP3DIR + 2676788
30  Electron Framework                  0x0000000106162a44 AtomMain + 68
31  Electron                            0x000000010615df26 main + 38

is this normal , or there is something we can do to suppress this crash?

I'm using the electron-vue template, and the hot-reloading often crashes because of this :-/

I hope you find some answer.
Cheers

from iohook.

DCzajkowski avatar DCzajkowski commented on August 20, 2024

Try quitting the app not by ctrl+c, but app.quit()

from iohook.

jlsilva1994 avatar jlsilva1994 commented on August 20, 2024

@DCzajkowski , thanks for the quick reply 😄
I'm using the app.quit() to quit the app.
the funny thing is when i use the cmd+c to quit, sometimes doesn't throw the error, but when i call the app.quit(), it always throws the error i shown you above 🤔

from iohook.

Djiit avatar Djiit commented on August 20, 2024

This is great! Thanks !
Would you mind opening a PR here with the updated ilbuiohook version?

from iohook.

serafimpinto avatar serafimpinto commented on August 20, 2024

With this current libuiohook branch (1.1) I did a manual build for macOS and the problems were resolved and my app worked like a charm. The only thing that I had to do to make the build run without errors was this change on file iohook.cc. Like @jlsilva1994 did.

However, on Windows, with the manual iohook build that I made I cannot run the electron app anymore. I got this error every time I try to run npm run dev.

┏ Electron -------------------

  refresh_locale_list [476]: GetKeyboardLayoutList(0, NULL) found 2 layouts.
  refresh_locale_list [493]: Received 2 locales.
  load_input_helper [866]: refresh_locale_list() found 2 locale(s).
  App threw an error during load
  Error: Module did not self-register.
      at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
      at Object.Module._extensions..node (module.js:671:18)
      at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
      at Module.load (module.js:561:32)
      at tryModuleLoad (module.js:504:12)
      at Function.Module._load (module.js:496:3)
      at Module.require (module.js:586:17)
      at require (internal/module.js:11:18)
      at Object.<anonymous> (C:\Users\user\Desktop\electron-app\node_modules\iohook\index.js:16:21)
      at Object.<anonymous> (C:\Users\user\Desktop\electron-app\node_modules\iohook\index.js:290:3)

┗ ----------------------------

I don't know if the cause is my Windows environment that could not have the right dependencies to make the iohook build or not. But the build went with success and without errors.

Right now I am stucked with this. @WilixLead is possible to make a new build with the currents changes of libuiohook? Thanks

from iohook.

towerofnix avatar towerofnix commented on August 20, 2024

@Djiit It doesn't look to be fixed. I did require('iohook'); process.exit(0), and it just hanged until I pressed ^C. No error output as in my first post, though.

from iohook.

Arduino1987 avatar Arduino1987 commented on August 20, 2024

Think this is related issue:
Electron v3.0.7, node v8.15.0. Ubuntu 16.04 x64.
"iohook": "^0.3.0"

main.js
const ioHook = require('iohook');

then just add simple tray from electron doc(https://electronjs.org/docs/api/tray):

after this click on tray icon and the app will close immediately

If I comment requiring 'iohook', all works as expected.

Sorry, seems its only on my Mate desktop. On default Ubuntu desktop no such issue.

from iohook.

kolnogorov avatar kolnogorov commented on August 20, 2024

Any news on here?

from iohook.

flameleo11p avatar flameleo11p commented on August 20, 2024

process.on('exit', () => {
iohook.unload();
});

process.exit(0);

return code not 0, but 139

output:
Segmentation fault (core dumped)
[Finished in 1.5s with exit code 139]


but my version is for ubuntu 1804LTS,
npm install [email protected]

from iohook.

ash0x0 avatar ash0x0 commented on August 20, 2024

Closing as irrelevant. This doesn't seem to be an issue anymore.

from iohook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.