Report pre-requisites
Clarity and Disclosure
Windows Version
Windows 11 25H2
Type of bug
Location
Application Name and Version
OpenMPT
MIDI Device
n/a
Vendor Driver
n/a
Output from the MIDI Diagnostics Tool
n/a
Repro
Your personal observation that led to the bug report
It appears that as of recently, Windows 11 runs a MIDI service component (MidiSrv) only on-demand, i.e. when an application first calls any of the MIDI API functions, such as midiInGetNumDevs(). Even on a Windows 11 system that has no MIDI devices at all attached (i.e. the only MIDI device listed by MMSYSTEM is the GM wavetable synth), the MIDI API call in question hangs for about ten seconds. Often, as is the case in OpenMPT, MIDI devices are enumerated on the GUI thread, to present a list of available MIDI devices. So this inevitably leads to a GUI hang, or the requested information not being available in the GUI.
If the application in question also suppports MME audio devices, any interaction with MME audio APIs such as enumerating audio devices appears to access the same internal structures as the MIDI device code, so even if you move your MIDI device enumeration code to a separate thread, the audio device code will still be blocked for the same duration if it happens to run at the same time (e.g. because the application enumerates available audio and MIDI devices on startup).
Steps to reproduce
See description above.
Additional notes
I fully understand that the MIDI component is not important to every Windows 11 user, so it is not started automatically to keep startup times lean for such users. However, this comes at the expense of music producers who now either have an inevitable hang, or have their MIDI devices being unavailable on first use. I wonder if the MIDI service could instead be started with a delay and low priority, so that it does not affect Windows 11 startup time for regular users, but doesn't block MIDI device enumeration and other API calls by the time a user is likely to use these APIs for the first time.
I tried to see if I can request the service to be started programmatically when launching OpenMPT, but it appears that this is a privileged operation that a non-admin Windows user cannot invoke. So my only workaround right now is to call midiInGetNumDevs() on a separate thread while OpenMPT starts up, and then hope that the user doesn't do anything that would require MME audio or MIDI devices to be enumerated, otherwise the GUI will just freeze.
Report pre-requisites
Clarity and Disclosure
Windows Version
Windows 11 25H2
Type of bug
Location
Application Name and Version
OpenMPT
MIDI Device
n/a
Vendor Driver
n/a
Output from the MIDI Diagnostics Tool
n/a
Repro
midi.exe,midi1monitor.exeorPocket MIDIYour personal observation that led to the bug report
It appears that as of recently, Windows 11 runs a MIDI service component (MidiSrv) only on-demand, i.e. when an application first calls any of the MIDI API functions, such as
midiInGetNumDevs(). Even on a Windows 11 system that has no MIDI devices at all attached (i.e. the only MIDI device listed by MMSYSTEM is the GM wavetable synth), the MIDI API call in question hangs for about ten seconds. Often, as is the case in OpenMPT, MIDI devices are enumerated on the GUI thread, to present a list of available MIDI devices. So this inevitably leads to a GUI hang, or the requested information not being available in the GUI.If the application in question also suppports MME audio devices, any interaction with MME audio APIs such as enumerating audio devices appears to access the same internal structures as the MIDI device code, so even if you move your MIDI device enumeration code to a separate thread, the audio device code will still be blocked for the same duration if it happens to run at the same time (e.g. because the application enumerates available audio and MIDI devices on startup).
Steps to reproduce
See description above.
Additional notes
I fully understand that the MIDI component is not important to every Windows 11 user, so it is not started automatically to keep startup times lean for such users. However, this comes at the expense of music producers who now either have an inevitable hang, or have their MIDI devices being unavailable on first use. I wonder if the MIDI service could instead be started with a delay and low priority, so that it does not affect Windows 11 startup time for regular users, but doesn't block MIDI device enumeration and other API calls by the time a user is likely to use these APIs for the first time.
I tried to see if I can request the service to be started programmatically when launching OpenMPT, but it appears that this is a privileged operation that a non-admin Windows user cannot invoke. So my only workaround right now is to call
midiInGetNumDevs()on a separate thread while OpenMPT starts up, and then hope that the user doesn't do anything that would require MME audio or MIDI devices to be enumerated, otherwise the GUI will just freeze.