-
Notifications
You must be signed in to change notification settings - Fork 80
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
fix: Windows hangs when closing midi input #151
Conversation
@Boddlnagg does this look like an intermittent failure? https://dev.azure.com/Boddlnagg/midir/_build/results?buildId=290&view=logs&j=2ae84081-e78e-5a7a-8f41-ad37cdcf10e4&t=b918b31c-3069-5944-d0e6-943aa58d75cf I don't think any of these changes would cause an issue with the linker, but maybe I'm wrong. |
actually, I may need to do some more debugging. I think the build failure is a fluke, but it looks like I'm still seeing the same bug. |
all right, sorry for the confusion. The fix is verified as working. I made a mistake in my As an aside, this crate has made my life a lot easier and I just wanted to say thank you for making and maintaining it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for figuring this out and providing a fix!
Do you have any idea why the |
I'm guessing it's just spurious, but I don't know how to re-run the pipeline. Do you have any instructions on how to re-run a pipeline that's spuriously failing? |
It looks like it builds parking_lot fine here: https://dev.azure.com/Boddlnagg/midir/_build/results?buildId=290&view=logs&j=2ae84081-e78e-5a7a-8f41-ad37cdcf10e4&t=26f8685c-4e6b-5527-1b2b-b6154ff0fd7a Here's what I'm trying to reproduce the failure:
This is unfortunate. I don't see a good solution here. The most common compiler/linker for windows (MSVC) works fine. I'm not sure what's unique about We could make the re-entrant mutex conditional on using MSVC, but now mingw will build but the code will behave incorrectly. |
potential fix: it seems like mingw issue might be fixed by dynamically linking to windows SDK: ardaku/whoami@8c673fe |
Interesting, it looks like updating |
all right, now it seems like the tradeoff is between supporting mingw and updating midir to use a newer version of the |
1bd48c6
to
f896fde
Compare
* Mutexes in Windows are re-entrant, but `std::sync::Mutex` is not. * If a sysex message is inbound when closing a MIDI input windows will hang because part of the call to `midiInReset` will cause the input handler to fire, but the `HMIDIIN` lock was already taken before that handler attempts to take the lock a second time. * All of this takes place in a single thread, so there's no risk in allowing the lock to be taken twice. * `parking_lot::ReentrantMutex` is used in place of `Mutex`. * This change should behave more like `rtmidi` (which some of this code is based on) as `rtmidi` is also using a re-entrant mutex. * Tested on Windows 10, and issue appears resolved. * Update `windows` from `0.43` to `0.56` to resolve mingw-specific issues. * Minor changes to `winrt` code to accomodate update to `windows` crate. Fixes Boddlnagg#150 Fixes Boddlnagg#152
@Boddlnagg we are good to go. 😀 |
Thanks again! I just released version 0.10.0 with this fix (and other changes that had accumulated). |
Right on. The timely release is much appreciated :) |
std::sync::Mutex
is not.midiInReset
will cause the input handler to fire, but theHMIDIIN
lock was already taken before that handler attempts to take the lock a second time.parking_lot::ReentrantMutex
is used in place ofMutex
.rtmidi
(which some of this code is based on) asrtmidi
is also using a re-entrant mutex.Fixes #150