bitfocus / companion-module-generic-midi

MIT License
3 stars 3 forks source link

Module crashes on load with Roland UVC-02 Device on Windows #4

Open herzogmedia opened 2 months ago

herzogmedia commented 2 months ago

When starting the module in current companion (3.3.1), it crashes with the following log output:

system: ** Starting Connection from "C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js" **
system: ** Connection started **
Starting up module class: W
Sentry disabled
Module-host accepted registration
Available MIDI Inputs:  [ 'Roland UVC-02', 'BMT 1', 'BMT 2' ] 
    Selected MIDI Input:   Roland UVC-02
Available MIDI Outputs: [ 'Microsoft GS Wavetable Synth', 'Roland UVC-02', 'BMT 1', 'BMT 2' ] 
    Selected MIDI Output:  Microsoft GS Wavetable Synth

error: MidiInWinMM::openPort: error creating Windows MM MIDI input port.

error: Trace: Init failed: Error: Internal RtMidi error
    at C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:366559
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:335601
error: Failed to init: Error: Internal RtMidi error Error: Internal RtMidi error
    at r.openPort (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:680)
    at new C (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:398154)
    at W.configUpdated (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:401178)
    at W.init (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:400507)
    at C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:366495
    at C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:335440
    at t.default._tryToStartAnother (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:334487)
    at C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:335647
    at new Promise (<anonymous>)
    at t.default.add (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:335290)
system: ** Connection stopped **

Is this related to the WinMM-Library?

MeestorX commented 2 months ago

I wonder if there's an issue with the Roland driver. If you choose a different MIDI input, does it still crash?

herzogmedia commented 2 months ago

Where would I choose a MIDI port? It crashes before I get to the config screen. I'll later try to start the module with the roland disconnected and get back to you

MeestorX commented 2 months ago

Yes, unplug the Roland and see what happens. If that fixes the issue then check and see if there's an updated drive for the Roland.

herzogmedia commented 2 months ago

So this indeed fixes the issue. Unfortunately, there is no new driver for the Roland but now that the module loads properly, I can choose a different MIDI device in config and it then still loads after plugging the Roland back in

herzogmedia commented 2 months ago

for the module it would be nice to be able to change the midi device and reload the module instead of it crashing completely

MeestorX commented 2 months ago

Ok, just so I'm clear, if you have the Roland disconnected and load the module, it runs properly. Then, you connect the Roland, and if you select it in the Module's config, does it again crash the module? You're right, the module should try and recover from an error like that if possible. Does this Roland interface work with other software properly? I think that a bug report should be made for RtMidi, as it is the one actually crashing. They may just say though that since WinMM (A Microsoft library) is the one with the error that it cannot be fixed and would require a fix from Roland. Lots of finger pointing I expect, or more likely, no response at all from Roland...

MeestorX commented 2 months ago

I'll create a bug report for rtMidi, maybe you can fill in your Windows info and/or send a bug report to Roland too? https://github.com/thestk/rtmidi/issues/339

herzogmedia commented 2 months ago

Ok, just so I'm clear, if you have the Roland disconnected and load the module, it runs properly.

Yes.

Then, you connect the Roland, and if you select it in the Module's config, does it again crash the module?

Not directly. If I select it in config and save, nothing happens. If I restart the module (or companion) with the Roland selected, it crashes again.

Does this Roland interface work with other software properly?

That is hard to say, since Roland does not mention MIDI at all in their documentation. After some digging and testing, I found out that they seem to use MIDI to communicate between their desktop software and the device. So the errors come from the device already beeing used by another application.

MeestorX commented 2 months ago

I had assumed it was a USB to MIDI adapter, but it's a MIDI device. Good chance it's not a "general MIDI-type" device and is a proprietary device for Roland software only. If it doesn't work with other MIDI software, then there's no reason to think it should work with my module. But... You're not wrong about the crashing, it would be good to NOT have that happen - have it simply not work instead of crashing.

herzogmedia commented 2 months ago

If it doesn't work with other MIDI software, then there's no reason to think it should work with my module.

I totally agree. And I do not expect it to. My bug report was more about the fact, that it crashes before letting me choose a different device.

MeestorX commented 2 months ago

I added some error handling to the module, you can download it here: https://discourse.checkcheckonetwo.com/t/v3-rcp-module-installation-instructions/3458 If you don't have an account, create one and send me a dm so I can raise your trust level so you can download. Alternately, you can send me a DM there with your e-mail address and I can send you a link. Would appreciate it if you could test it as I don't have a "bad" device to try it with...

MarekPro1 commented 2 months ago

Hello I have the same issue but I am not using Roland drivers indeed I am using BOME network app, but even when I close the app it crashes the same. I am on windows newest beta wersion, midi connections ready. But it crashes.

ystem: Log cleared system: Starting Connection from "C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js" system: Connection started Starting up module class: W Sentry disabled Module-host accepted registration Available MIDI Inputs: [ 'Ableton-FOH' ] Selected MIDI Input: Ableton-FOH Available MIDI Outputs: [ 'Microsoft GS Wavetable Synth', 'Ableton-FOH' ] Selected MIDI Output: Microsoft GS Wavetable Synth

error: MidiOutWinMM::openPort: error creating Windows MM MIDI output port.

error: Trace: Init failed: Error: Internal RtMidi error at C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:366559 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:335601 error: Failed to init: Error: Internal RtMidi error Error: Internal RtMidi error at a.openPort (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:1052) at new y (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:399085) at W.configUpdated (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:401231) at W.init (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:400507) at C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:366495 at C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:335440 at t.default._tryToStartAnother (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:334487) at C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:335647 at new Promise () at t.default.add (C:\Program Files\Companion\resources\bundled-modules\generic-midi\main.js:1:335290)

MeestorX commented 2 months ago

Thank you for letting me know. Can you confirm what version of the generic-MIDI module you're running? (Click on the ? beside the module name)

MarekPro1 commented 2 months ago

Hello 1.1.7 image

MeestorX commented 2 months ago

Copy that. If you are able, please try 1.1.8 and let me know if that fixes the problem. https://discourse.checkcheckonetwo.com/t/companion-v3-x-x-modules-for-yamaha-and-the-new-generic-midi-module

MarekPro1 commented 2 months ago

Yes I can test it, but still after the years I don't know how to upgrade plugins in companion :(

MeestorX commented 2 months ago

Ok, you should be good now.

MarekPro1 commented 2 months ago

Hello, I got the new version 1.1.8 but it does the same. image

` Starting up module class: ModuleInstance Sentry disabled Module-host accepted registration Available MIDI Inputs: [ 'Ableton-FOH' ] Selected MIDI Input: Ableton-FOH Available MIDI Outputs: [ 'Microsoft GS Wavetable Synth', 'Ableton-FOH' ] Selected MIDI Output: Microsoft GS Wavetable Synth

error: MidiOutWinMM::openPort: error creating Windows MM MIDI output port.

error: Trace: Init failed: Error: Internal RtMidi error at eval (webpack://generic-midi/./node_modules/@companion-module/base/dist/module-api/base.js?:117:25) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async run (webpack://generic-midi/./node_modules/p-queue/dist/index.js?:163:29) error: Failed to init: Error: Internal RtMidi error Error: Internal RtMidi error at Output.openPort (webpack://generic-midi/./node_modules/@julusian/midi/midi.js?:69:24) at new Output (webpack://generic-midi/./dist/midi/midi.js?:104:34) at ModuleInstance.configUpdated (webpack://generic-midi/./dist/main.js?:60:27) at ModuleInstance.init (webpack://generic-midi/./dist/main.js?:37:20) at eval (webpack://generic-midi/./node_modules/@companion-module/base/dist/module-api/base.js?:113:28) at run (webpack://generic-midi/./node_modules/p-queue/dist/index.js?:157:104) at PQueue._tryToStartAnother (webpack://generic-midi/./node_modules/p-queue/dist/index.js?:105:17) at eval (webpack://generic-midi/./node_modules/p-queue/dist/index.js?:171:18) at new Promise () at PQueue.add (webpack://generic-midi/./node_modules/p-queue/dist/index.js?:152:16) system: Connection stopped `

MeestorX commented 2 months ago

@Julusian - What's the best way to handle an error like this from RtMidi when trying to open a bad port? This doesn't seem to be doing it. https://github.com/bitfocus/companion-module-generic-midi/blob/e73ea37488dfc081ea67dec852292c7213270d73/src/midi/midi.ts#L29-L33

I basically just want the module to ignore bad ports and not crash the module.

Julusian commented 1 month ago

@MeestorX I see no reason why that catch wouldn't work. The error is definitely being thrown as a js exception, so would be caught by that.

I think you forgot to do a yarn build to compile the typescript before building the module. Looking at the compiled code of the module (freshly downloaded from your website), it looks like this: image It's a mess (because of webpack), but notice that there isn't a try/catch around it.

MeestorX commented 1 month ago

Oh! I didn't know about yarn build. I don't ever remember executing that command. The "watcher" that restarts companion when you make changes while running in dev mode doesn't automagically run that command?

Julusian commented 1 month ago

running yarn dev in this repository would. but no companion won't do that for you as it doesn't know about converting module typescript to javascript.

I am wondering if perhaps the yarn companion-module-build command should be made to do typescript transpilation automatically, but that will require some thought on how to tell it to do so. it currently uses the same entrypoint js file as companion does, but this would mean they would need different values

MeestorX commented 1 month ago

Copy that. No problem. I'll just have to remember that extra step from now on with TS modules.

MeestorX commented 1 month ago

It's been rebuilt now and hopefully should fix the problem for you, @herzogmedia and @MarekPro1. LMK!

MeestorX commented 1 month ago

Are either of you able to try this? I don't have a bad MIDI device with which to test it. @herzogmedia @MarekPro1

MarekPro1 commented 1 month ago

I can test it next week. soonest

On Fri, 19 Jul 2024 at 21:22, Andrew Broughton @.***> wrote:

Are either of you able to try this? I don't have a bad MIDI device with which to test it. @herzogmedia https://github.com/herzogmedia @MarekPro1 https://github.com/MarekPro1

— Reply to this email directly, view it on GitHub https://github.com/bitfocus/companion-module-generic-midi/issues/4#issuecomment-2239973427, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2NQ3LFXTMQQDMN7MCBEXT3ZNFRRFAVCNFSM6AAAAABJFZVX2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZZHE3TGNBSG4 . You are receiving this because you were mentioned.Message ID: @.***>

MeestorX commented 3 weeks ago

Has anyone had a chance to test this yet?

MarekPro1 commented 1 week ago

Has anyone had a chance to test this yet?

I am going to.