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

State change events do not seem to be firing in Node.js #8

Open
djipco opened this issue May 6, 2022 · 7 comments
Open

State change events do not seem to be firing in Node.js #8

djipco opened this issue May 6, 2022 · 7 comments

Comments

@djipco
Copy link

djipco commented May 6, 2022

I am trying to detect when a device is being connected or disconnected but state change events do not seem to be firing. Here is a bit of code that demonstrates the problem:

const navigator = require("jzz");

navigator.requestMIDIAccess().then(interface => {

  console.log("Enabled!");

  interface.onstatechange = function (e) {
    console.log(e);
  }

});

If I run this code in Node.js, I do see "Enabled!" in the console. However, if I try to plug or unplug a device, nothing happens. I was expecting the onstatechange function to be triggered. Are my expectations wrong? Or perhaps there is something else at play?

This is on macOS Monterey with Node v17.8.0

@jazz-soft
Copy link
Owner

Thanks a lot for the notice! Will try to fix it during the weekend...

@jazz-soft jazz-soft transferred this issue from jazz-soft/JZZ May 10, 2022
@jazz-soft
Copy link
Owner

The issue seems to be in the jazz-midi module. I guess it will take some more time to fix...

@djipco
Copy link
Author

djipco commented Jun 27, 2022

Do you have an ETA for the fix ?

@jazz-soft
Copy link
Owner

Sorry, have to be patient...

@jdlee022
Copy link

Any update on this?

thirtythreeforty added a commit to thirtythreeforty/jazz-midi that referenced this issue Oct 10, 2023
The pthread and lock are never created if the "if" in the constructor
fails, and the members are never initialized.  But the destructor
unconditionally destroys them.  Fix this by adding a guard flag.

This fixes a segfault I encountered on Arch with Pipewire as the ALSA
server.

    Thread 1 "node" received signal SIGSEGV, Segmentation fault.
    0x00007ffff428aebd in pthread_cancel () from /usr/bin/../lib/libc.so.6
    (gdb) bt
    #0  0x00007ffff428aebd in pthread_cancel () from /usr/bin/../lib/libc.so.6
    jazz-soft#1  0x00007ffff3b773ff in CMidiInHW::~CMidiInHW (this=0x55555572a430, __in_chrg=<optimized out>) at ../../midi/MidiALSA.cpp:366
    jazz-soft#2  0x00007ffff3b77452 in CMidiInHW::~CMidiInHW (this=0x55555572a430, __in_chrg=<optimized out>) at ../../midi/MidiALSA.cpp:369
    jazz-soft#3  0x00007ffff3b77105 in CMidiALSA::MidiInOpen[abi:cxx11](wchar_t const*, void*) (this=0x5555557b9880, name=0x5555556b3cf0 L"input", p=0x55555579e3a0) at ../../midi/MidiALSA.cpp:329
    jazz-soft#4  0x00007ffff3b6f0c8 in MidiInOpen (env=0x55555579e410, args=0x7fffffff9e20) at ../jazz-midi.cpp:461
    jazz-soft#5  0x00007ffff535bd33 in ?? () from /usr/bin/../lib/libnode.so.115
    jazz-soft#6  0x00007ffff5840d97 in ?? () from /usr/bin/../lib/libnode.so.115
    jazz-soft#7  0x00007ffff5841942 in v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) () from /usr/bin/../lib/libnode.so.115
    jazz-soft#8  0x00007ffff56cadf6 in ?? () from /usr/bin/../lib/libnode.so.115
@djipco
Copy link
Author

djipco commented Aug 6, 2024

I just tried it with jzz 1.8.5 and the problem is still there.

@jazz-soft
Copy link
Owner

Unfortunately I'm swamped with other stuff...
I would appreciate if anybody could fix it...

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

No branches or pull requests

3 participants