Widnows 11 Windows::Media::Audio::AutoPlaybackConnection::Start() method causes application crashi
Hello,
I have an application that that uses Windows.Media.Audio.AudioPlaybackConnection.Start() method, and it started crashing on Windows 11. After debugging, I found that the Start() method internally calls Windows.Media.Devices.dll!TraceLoggingRegisterEx_EventRegister_EventSetInformation() routine after its real work is finished (in my case, it succeed). But, the TraceLoggingRegisterEx_EventRegister_EventSetInformation routine is coded like the following (reconstructed pseudo code based on the disassembled code)
[onecore\internal\minwin\priv_sdk\inc\TraceLoggingProvider.h]
TraceLoggingRegisterEx_EventRegister_EventSetInformation(const _tlgProvider_t * hProvider, ...) {
if (hProvider->RegHandle != nullptr) {
_fastfail(FAST_FAIL_INVALID_ARG); // ** This is new in Windows 11. No __fastfail() in Windows 10 **
}
EventRegister(... , &hProvider->RegHandle);
...
}
Problems of this code are:
- Windows.Media.Audio.AudioPlaybackConnection.Start() method can be called multiple times. So, when this method is called for the 2nd time, hProvider->RegHandle is not null. IMHO event registration should be done only once somewhere else. Not when the event occurred. (this is a problem since Windows 10)
- And, more importantly, API should not call __fastfail() for its internal ETW logging logic error. (It may be ok to do so in the checked build, but not in the release build)
I think this is an easy bug to fix and will be addressed soon. If you have any questions, please let me know.
Thanks.