blish-hud / Blish-HUD

A Guild Wars 2 overlay with extreme extensibility through compiled modules.
https://blishhud.com
MIT License
322 stars 59 forks source link

Fatal Crash: System.IO.FileNotFoundException: Not implemented When Starting Guild Wars 2 #724

Closed twittyc closed 2 years ago

twittyc commented 2 years ago

BlishHUD crashes when Guild Wars 2 starts with the following stack trace:

Blish HUD v0.11.7+Branch.tags-v0.11.7.Sha.0c709c76cb502d310f2964dca92ce770e533dae2
09:46:32.7652 | INFO  | Blish_HUD.Program | Running Build "Branch.tags-v0.11.7.Sha.0c709c76cb502d310f2964dca92ce770e533dae2"
09:46:32.7652 | INFO  | Blish_HUD.Program | Launched from "C:\Users\ctwit\Downloads\Blish.HUD.0.11.7" with args "".
09:46:34.5390 | FATAL | Blish_HUD.DebugService | Blish HUD encountered a fatal crash!
System.IO.FileNotFoundException: Not implemented

Not implemented

   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at NAudio.CoreAudioApi.AudioSessionManager.RefreshSessions()
   at NAudio.CoreAudioApi.MMDevice.GetAudioSessionManager()
   at Blish_HUD.GameIntegration.AudioIntegration.InitializeProcessMeterInformations() in D:\a\Blish-HUD\Blish-HUD\Blish HUD\GameServices\GameIntegration\AudioIntegration.cs:line 167
   at Blish_HUD.GameIntegration.AudioIntegration.UpdateAudioDevice() in D:\a\Blish-HUD\Blish-HUD\Blish HUD\GameServices\GameIntegration\AudioIntegration.cs:line 153
   at Blish_HUD.GameIntegration.AudioIntegration.Load() in D:\a\Blish-HUD\Blish-HUD\Blish HUD\GameServices\GameIntegration\AudioIntegration.cs:line 77
   at Blish_HUD.GameService.DoLoad() in D:\a\Blish-HUD\Blish-HUD\Blish HUD\GameServices\GameService.cs:line 58
   at Blish_HUD.BlishHud.BeginRun() in D:\a\Blish-HUD\Blish-HUD\Blish HUD\BlishHud.cs:line 93
   at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
   at Blish_HUD.Program.Main(String[] args) in D:\a\Blish-HUD\Blish-HUD\Blish HUD\Program.cs:line 97

I tried digging into it a bit, but I'm not sure what file it's expecting.

twittyc commented 2 years ago

Looks like it may be related to the mutex check.

dlamkins commented 2 years ago

It appears to be somewhere in our NAudio dependency: https://github.com/naudio/NAudio/blob/fb35ce8367f30b8bc5ea84e7d2529e172cf4c381/NAudio.Wasapi/CoreAudioApi/AudioSessionManager.cs#L90-L102

I don't see any connection to our mutex check. The line numbers here are slightly off so that may have caused some confusion.

I'm fairly certain this is the line in our code that is crashing: https://github.com/blish-hud/Blish-HUD/blob/10a9618524828fafa90148b1ff82a921b1960c1e/Blish%20HUD/GameServices/GameIntegration/AudioIntegration.cs#L174

We can look at expanding the try/catch there to cover this, but can you confirm if you have any unique audio devices like virtual audio cables or anything like that configured? This code is attempting to detect your default device for Guild Wars 2 by enumerating the audio sessions and then checking their PID to see if they match the GW2 one. If they do, we measure the audio levels on that audio device to try and match our volume.

twittyc commented 2 years ago

Hi, thanks for the reply. image Here's a screenshot of my sound devices.

twittyc commented 2 years ago

Ok, so I was going to set up the debugger and see if I could resolve this myself. However, when running the local build of Blish HUD. I didn't experience any crashing.

dlamkins commented 2 years ago

Ahh! It could be that we've already solved this in our prereleases. Could you check if you have the issue in our latest prerelease or build from CI?

twittyc commented 2 years ago

So I'm only seeing 8 Releases and 8 Tags and no prerelease branches. Not sure if I don't have permission to see it or what. The above error was using the latest release v0.11.7.

Here is what I did to debug: I cloned the dev branch and went to build it locally and noticed a compilation error with AudioIntegration.cs the last import using NAudio.CoreAudioApi; wasn't in the NuGet packages, only NAudio.Wasapi. So I pulled in the base NAudio and was able to compile it for debugging. I then launched the app followed by Guild Wars 2 and didn't get the error anymore. Anyway, IDK if these steps are helpful or not :)

dlamkins commented 2 years ago

Great! That should confirm we are good on the latest builds then. We only host the prereleases on a separate repo (or linked in our discord channel) so you'd have to pull it from the CI otherwise.

If the build from source worked, that means it will be working for you in the next release and we've already got it fixed. 😁

twittyc commented 2 years ago

Yeah, you're right I just pulled the latest nightly build from Actions and it worked without crashing :)

dlamkins commented 2 years ago

Thanks for your patience in all of that. Glad we were able to confirm. I'll go ahead and close since we have it fixed in the latest dev builds. Don't hesitate to reach out if you run into any other issues. 👍