Pathoschild / SMAPI

The modding API for Stardew Valley.
https://smapi.io/
GNU Lesser General Public License v3.0
1.86k stars 263 forks source link

SEHException when initialising audio #431

Closed Pathoschild closed 6 years ago

Pathoschild commented 6 years ago

Some players intermittently get this error:

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at new[](UInt32 )
   at Microsoft.Xna.Framework.Audio.UnsafeNativeMethods.AllocateArrayAndReadFile(String filename, Void** ppData, UInt32* pdwBufferSize)
   at Microsoft.Xna.Framework.Audio.UnsafeNativeMethods.WaveBank.CreateHandle(UInt32 hEngine, String string, Int32 length, IntPtr& pCleanup)
   at Microsoft.Xna.Framework.Audio.WaveBank..ctor(AudioEngine audioEngine, String nonStreamingWaveBankFilename)
   at StardewValley.Game1.Initialize() in C:\Users\tomc\Documents\Visual Studio 2010\Projects\Stardew.XNA\Farmer\Farmer\Game1.cs:line 535
   at StardewModdingAPI.Inheritance.SGame.Initialize() in D:\source\SMAPI\src\StardewModdingAPI\Inheritance\SGame.cs:line 301
   at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
   at Microsoft.Xna.Framework.Game.Run()
   at StardewModdingAPI.Program.StartGame() in D:\source\SMAPI\src\StardewModdingAPI\Program.cs:line 259

Investigate, and either fix or document the workaround.

Pathoschild commented 6 years ago

Known facts

Reported fixes

Players have variously fixed it by...

Known cases

user OS cause links
@Dexruus Windows 7 Professional Voicemeeter app report, log
vaindil commented 6 years ago

Possible fix here from reddit? There's a well-known program for toggling this, aptly named Large Address Aware. Something to try, at least.

I tried reinstalling the game/xna/updating audio drivers/etc and nothing seemed to help. The fix that worked for me was to edit "Stardew Valley.exe" to be large address aware. This can be accomplished with the editbin utility that comes with any version of Microsoft Visual Studio.

Running this makes the game large address aware (with the file paths changed to be whatever is correct on your computer):

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64>editbin /LARGEADDRESSAWARE "C:\GOG Games\Stardew Valley\Stardew Valley.exe"

After this fix I no longer get the crash on launch and am able to play the game. Hope this helps someone!

Dexruus commented 6 years ago

As requested in #430 heres the Voicemeter site https://www.vb-audio.com/Voicemeeter/index.htm edit: in terms of variously fixing it: XNA complete removal and reinstallation, even the steam provided one, didnt help yet, so aint gonna be XNAs fault this time; neither is discord or anything other; seems to be an playback device issue as related in #430 ; the moment voicemeter and Virtual Audiocable are disabled, mostly by deinstalling, Stardew is working. Its still interesting tho why its not working then tho.

Pathoschild commented 6 years ago

@vaindil Thanks! It's not something I'd recommend due to the disadvantages, but it's a clue to look into.

@Dexruus Can you post your SMAPI log after the error happens? How much RAM does your computer have?

Dexruus commented 6 years ago

16 GBs of RAM, 64 Bits, so usable Error log is still the same as in #430 : [19:09:34 INFO SMAPI] SMAPI 2.4 with Stardew Valley 1.2.33 on Microsoft Windows 7 Professional [19:09:34 DEBUG SMAPI] Mods go here: C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Mods [19:09:34 TRACE SMAPI] Log started at 2018-01-28T18:09:34 UTC [19:09:34 TRACE SMAPI] Overriding content manager... [19:09:35 TRACE SMAPI] Starting game... [19:09:41 ERROR SMAPI] The game failed unexpectedly: System.Runtime.InteropServices.SEHException (0x80004005): Eine externe Komponente hat eine Ausnahme ausgelöst. bei new bei Microsoft.Xna.Framework.Audio.UnsafeNativeMethods.AllocateArrayAndReadFile(String filename, Void* ppData, UInt32 pdwBufferSize) bei Microsoft.Xna.Framework.Audio.UnsafeNativeMethods.WaveBank.CreateHandle(UInt32 hEngine, String string, Int32 length, IntPtr& pCleanup) bei Microsoft.Xna.Framework.Audio.WaveBank..ctor(AudioEngine audioEngine, String nonStreamingWaveBankFilename) bei StardewValley.Game1.Initialize() bei Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun) bei Microsoft.Xna.Framework.Game.Run() bei StardewModdingAPI.Program.RunInteractively() in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:Zeile 226. [19:09:41 INFO SMAPI] Game has ended. Press any key to exit.

Pathoschild commented 6 years ago

@Dexruus Can you replace your Stardew Valley.exe file with the attached one, and see if that fixes it? (Don't forget to back up the old one.)

Dexruus commented 6 years ago

Will try tomorrow evening, its already pretty late here; will edit this when i tried.

Dexruus commented 6 years ago

Ok whatever you did seems to work properly. Stardew is up and running better than ever. Can confirm as fixed. Curious now what it was tho; If you need any log files to recycle, let me know.

Pathoschild commented 6 years ago

Stardew Valley is 32-bit, so normally it can only access 2GB of RAM. I marked Stardew Valley.exe as large address aware, meaning it can access more of your available RAM. The game itself should be fine, but I'm not sure about XNA Framework. Let me know if you run into any problems; if not, I'll add that to the FAQs as a workaround. 🙂

Pathoschild commented 6 years ago

This is a game limitation, so there's not much we can do about it. The workarounds are now documented on the wiki.

Sellec commented 6 years ago

Another way to solve this - applying Large Address Aware to StardewModdingAPI.exe. Only this solves problem for me.

Pathoschild commented 6 years ago

Turns out the vanilla game sets the 'large address aware' flag, so it's safe for SMAPI to do it too. I'll add that to the build on Windows.

Pathoschild commented 6 years ago

Fixed in develop for the upcoming SMAPI 2.6-beta.17.