3.6 (maybe 3.5 too) has xAudio2_7.dll crashes after 15 minutes of game running

We’re using Wwise as our sound middleware. After upgrading to Windows 10 and moving from Monogame 3.4 to 3.6 I’ve discovered that our game crashes 15 minutes in, consistently due to xAudio2_7.dll unloading. This causes an Access Violation exception to be thrown.

‘Super Daryl Deluxe.exe’ (Win32): Unloaded ‘C:\Windows\SysWOW64\XAudio2_7.dll’
Exception thrown at 0x0F25A5E0 in Super Daryl Deluxe.exe: 0xC0000005: Access violation executing location 0x0F25A5E0.

It has taken me a day and a half to determine that this is what’s happening after discovering that the game always crashes after 15 minutes. I temporarily switched back to 3.4 and the issue was gone.

Here is a post detailing the cause and potential fix for this issue, perhaps it can be applied to Monogame:

This is a rather common bug in other games it seems, ranging from Assassins Creed to Far Cry to some Bethesda games.

More threads about it:

There are a few suggested fixes (such as disabling random Windows 10 services or removing a .dll from System32), but they don’t work universally and frankly it isn’t acceptable for users to mess with that sort of thing in order to play games.

I’m not sure if this is happening in 3.5 as well, but I do know it’s happening both in 3.6 AND the development branch, but it does not happen in 3.4

I’m more than willing to help solve this if anyone has any insight on where to start or what may have been changed to start causing this problem. I don’t want to move back to 3.4, despite the other issues I’ve been having with 3.6.

I’m thinking maybe SharpDX implemented the fix for this, but that needs investigating.

I think we might be unique here in using wwise with Monogame, but if anyone else has this particular issue you can try targeting wasapi instead of xaudio with Wwise to get rid of the error. So far it works fine, although I haven’t tested extensively yet. I do know that it doesn’t crash after 15 minutes, though.

I’d still like to try and solve the xaudio issue, as xaudio is preferred/suggested for Wwise.

I had the same issue with a xna game. it happens if you load/play the sounds in a different thread.

This is totally possible, but a slightly different problem unfortunately. I don’t load or use any SoundEffects in our game; it’s all done through the Wwise API. I suppose they’re both using xAudio though, so perhaps the root cause is the same.

It seems that just by having a reference to the xAudio .dll the problem is created. I’ve tested by only creating the Wwise object in our game and never loading/playing any sounds then letting the game sit idle for 15 minutes before it crashes. I suspect that the fix I posted above in the OP might work, but I don’t know where/how to integrate it with Monogame.