-
Notifications
You must be signed in to change notification settings - Fork 119
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
rewrite on node-api #228
base: master
Are you sure you want to change the base?
rewrite on node-api #228
Conversation
Hi @Julusian, |
Hey @hrueger |
Thanks a lot. I've tested it with my fork of |
Hi @Julusian, I'm pretty sure that this comes from the midi lib, because if I inspect c1a2c659-3a32-4012-a1e8-2a3fce594131.tmp.node using any text editor, I find some ASCII text about Midi: |
no that stack trace doesnt really say anything useful.. what version of electron are you using? and it looks like this is happening on windows for you? |
It's Electron |
ok, I suspect this is hitting https://www.electronjs.org/blog/v8-memory-cage. But Im surprised it only crashes occasionally. Would you be able to give it a try with electron 19? If it doesnt crash there, then that would confirm this to be the issue If this is the cause of the crash, then you might have other issues, as that 'rare' pattern does not look that rare to me (eg https://github.com/node-hid/node-hid/blob/master/src/HID.cc#L166 https://github.com/Julusian/node-jpeg-turbo/blob/master/src/compress.cc#L68) |
Interesting. Sure, I'll try electron 19 but I don't think I'll get to that today. |
Ignore that idea, after quite some digging, it turns out that the memory-cage change applies to v21 not v20 like it is documented to be. Ill give the code a read and do a preemptive fix for electron 21, but a reproduction script would be really helpful |
https://sentry.internal.makepro-x.com/share/issue/b2dead00224847c4aea486ecd5b56f02/ I was able to upload the debug files to Sentry and trigger the bug again. Can you find anything useful in that stack trace now? |
yeah, that stack trace is a lot more meaningful now, but the place it is crashing is rather odd.. |
Good to hear. I'm trying to prepare a simple reproduction repo right now. I also had a problem with errors just saying "Internal RTPMidi Error" when trying to close and reopen ports. I'll get back to you soon. |
I think I forgot to tell you that I'm using it in a worker_thread as well as in the main thread. Hopefully I can recreate that in the test case repo. |
I just noticed that the |
OK, I finally got it crashing 😉 Please check out this repository: https://github.com/hrueger/midi-napi-tests
There are two problem scripts currently:
Does that help? If I can do anything to help debugging, just tell me. |
I don't know how to proceed right now. Perhaps I need to produce a build which does a lot of console logging to give an indication of where it got to? |
Note for myself: |
Hm, how many Midi Ports do you have on your system? I have about 8 created with loopMidi and a couple more from rtpMidi. It happens on windows for me, I don't have Ubuntu available to test, but I can try on the Mac tomorrow. |
That looks interesting, indeed. I wonder if that can do virtual Midi Ports on Windows? That would be really cool, because people would not have to use loopMidi to create a virtual port in order to connect two programs using Midi. |
Ah, that did it. I had a couple with loopmidi, but increasing that to 18 triggers it |
@hrueger Please give v3.0.0-3 a try. It is no longer crashing for me in your reproduction. |
Thanks a lot, that sounds great. I'll test that |
That fixed the crash 👍 Thanks a lot. |
These changes are published as https://www.npmjs.com/package/@julusian/midi, and is currently 100% api compatible
I have a project which will soon need midi support in nodejs, and so have been slowly working on porting it to node-api and preparing for bundling prebuilds in the npm package. There is some junk in this PR currently, I shall remove that once I hear from a maintainer that they would like to review/accept this PR.
I already have a growing collection of node-api based native modules that I maintain, are you interested in another maintainer here? I am happy to simply work on getting this PR merged, but maintenance here looks very quiet recently, it looks like you could do with some help.
I am happy that these changes have been tested on windows, mac and linux. Of course there could still be bugs, if anyone finds something do let me know!