keijiro / MidiJack

MIDI input plugin for Unity
697 stars 113 forks source link

MidiJack doesn't work after the build. #32

Open santimagames opened 6 years ago

santimagames commented 6 years ago

Hi,

Midijack is working perfectly in the editor but after a build it will not work at all.

I'm building it on Windows10 64bit with Unity version 2017.3.0p1 (64-bit).

I also tried it with a clean project, using your example CC scene, the result is the same.

My midi device is same as yours, nano kontrol.

Thank you

santimagames commented 6 years ago

I found a workaround and maybe the possible cause of the problem.

The workaround is to copy the original MidiJackPlugin.dll file from it's original Assets\MidiJack\Plugins\x64 folder to your built _Data\Plugins folder.

Do this before running your application, otherwise it will not let you overwrite the old .dll file. If you've already ran your app and quit it, you can see your app still working as a background process. The reason being a possible crash or a memory leak from the problematic old .dll I assume. Although I'm not too certain about this.

Maybe the reason for this problem is that Unity copying the 32bit dll into the build? Hard to say.

keijiro commented 6 years ago

I'm under the impression that the root cause of the problem is the same to Funnel's case:

https://github.com/keijiro/Funnel/issues/16#issuecomment-380004066

I think I should update the .meta file of the plugin, actually don't know why though.

santimagames commented 6 years ago

I see, but the first time this problem happened, I had just imported the unitypackage file. So the .meta file should have been automatically created, right?

keijiro commented 6 years ago

.meta files are included in the unitypackage file. I guess that they have a problem, so that they have to be removed and recreated.

santimagames commented 6 years ago

Yes I think that worked. Thanks.

Interestingly previous non-working builds also started to work as well.

I don't how that was possible :)

keijiro commented 6 years ago

Thanks for verifying. I'll update them on my side.

santimagames commented 6 years ago

Actually, I think the problem still persists. I thought it worked. Today I've updated the project to 2018.1 and same thing happened.

The other issue is, once you build and run the game, even though you quit the game, the game will linger in the task manager for a while. When you try to delete the game files, it will not let you (obviously). So I tried to delete everything one by one, it turns out the lingering file is no other than MidiJackPlugin.dll. You can delete everything else. So even after you quit the game, MidiJackPlugin.dll keeps running for a while. By the way, trying to end the task in the Task Manager doesn't do anything (it says "Access is denied" if you do it in the Details tab of the Task Manager). Fortunately after 5 minutes or so it will quit itself, so you don't need to reboot the computer.

I tried deleting all the meta files again before building the game, this time it did not work.

I also tried copying the original 64bit MidiJackPlugin.dll file to the built plugins folder, that did not work either. So nothing's working right now. I'll try to reboot after I post this message and will let you know.

santimagames commented 6 years ago

A reboot works. I wonder if this method will work without copying the MidiJackPlugin.dll to the built plugins folder.

santimagames commented 6 years ago

Hi, Keijiro.

Sorry to keep going back to the same issue but I can now confirm that this problem has got nothing to do with .meta files. The problem stems from the original dll file. Replacing the dll does not change anything contrary to what I've said before. Basically once you exit the game, the game will hang in the task manager for a few minutes after quitting, this includes the Unity editor itself. So when you build your game, quit Unity and start your game, you'll see that the Unity executable will linger in the task manager and MidiJack will not work. If you wait for a few minutes the executable will quit by its own, then you can run your game and MidiJack will definitely work. So it kind of works, as long as you wait for a few minutes between sessions.

santimagames commented 6 years ago

Hi, Keijiro.

Any updates on the issue?

Thanks.

MidnightGD commented 5 years ago

Hi, i have the same problem. On MacOs everything works fine but on Windows 10 MidiJack only works in the editor. I cant get it to work at all in builds.

Has @santimagames have you found a solution for this problem?

Knomer commented 5 years ago

Win 8.1 x64. Same problem. after build in MidiDriver.cs "var data" always zero

// Process the message queue.
            while (true) {
                // Pop from the queue.
                var data = DequeueIncomingData();
                if (data == 0) break;
MidnightGD commented 5 years ago

@keijiro can you help us with the problem? Are we missing something or is it maybe a bug?

keijiro commented 5 years ago

Currently I'm occupied with other tasks (mainly for Unite events), so unfortunately I don't have time to look into the issue.

MidnightGD commented 5 years ago

Thanks for you answer, even if its kind a bad news for us :D @Knomer have you made any progress with your problem?

BoxOfClicks commented 3 years ago

Also suffering from this issue - did anyone make any progress? Frustratingly the more up-to-date RtMidi project works fine for sending midi out but not receiving midi for me (LPD8 Win 10 x64). Who knew getting midi working would be so tricky.

keijiro commented 3 years ago

@BoxOfClicks Please use the RtMidi repository to report issues about RtMidi.

BoxOfClicks commented 3 years ago

Thanks @keijiro - happy to create an issue there too.

With regard to MidiJack, I've done a bit more investigation and it seems as though the MidiJack process never exits, causing any app that uses it to be put into a 'suspended' state when closed. At this point the app cannot be force quit, even through the terminal taskkill command.

Thus if, for example, you opened an application using MidiJack, you would be unable to delete or uninstall the app until restarting your machine. It also means it's not possible to have two apps (or app + editor) run without a machine restart between. If anyone has any pointers or knows a way to force terminate the process on app quit, that would be much appreciated.