tModLoader: tML crashes when changing default audio device (and sometimes at startup)

Version

Latest 1.4-preview

OS

Windows

Platform

Steam

This bug affects

Gameplay as a Player

Description

FAudio_platform_win32.c is less stable than the previous SDL2 + ffmpeg backend (though that had its own issues).

FAudio does not implement any recovery from AUDCLNT_E_DEVICE_INVALIDATED errors which can be returned from most IAudioClient methods, and instead hard-crashes. The recovery process mentioned in https://docs.microsoft.com/en-us/windows/win32/coreaudio/recovering-from-an-invalid-device-error

See also https://github.com/FNA-XNA/FAudio/issues/296

Log File

Natives (6).log Natives (7).log

Steps to reproduce

Simply disabling or switching your default audio device during the game can trigger a crash.

For those experiencing issues starting the game at all, I need more information on how to reproduce (what devices/drivers/default setups etc).

Perhaps a list of dxdiag outputs from users with startup issues, vs those without would be useful.

Expected Behavior

Game recovers and can play audio.

Actual Behavior

Hard crash, assertion error in Natives.log

Reproduction frequency

100% for most people.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 12
  • Comments: 26 (4 by maintainers)

Most upvoted comments

Current workaround is to revert to the SDL2+ffmpeg backend.

  1. Download IAudioClient-workaround.zip
  2. Navigate to your tModLoader steam folder (Right click in steam libraries games list and click Manage > Browse Local Files)
  3. Extract the zip into the folder (You should be prompted to replace 3 files.
  4. Check that the files were extracted to the right location (go to Libraries/Native/Windows and compare to the following screenshot) image

Note: To verify that the workaround is installed, you should see FAudio v21.10.0 in client.log rather than FAudio v22.9.1.

this is still an issue

Still an issue a little before the two year anniversary of this problem. 😕

Definitely not fixed in 2023.6.25.28

Disconnecting my Bluetooth headphones causes the game to crash. Workaround from https://github.com/tModLoader/tModLoader/issues/2863#issuecomment-1221975856 works and fixes the issue.

Meanwhile, the year was 2025, and the error had not been fixed ._.

Is there anything missing to move forward on this? The IS is up to date and the issue is easily reproducible. Hopefully we can see a fix pushed out in a minor or bug release in the near future.