Algorithman / SoundCenSe

Sound for Dwarf Fortress without the need of java :)
14 stars 2 forks source link

Too many sounds at once crash SoundCenSe #16

Open BitBlitObviMormon opened 6 years ago

BitBlitObviMormon commented 6 years ago

I use a lot of scripts while playing Dwarf Fortress' adventure mode and I noticed that SoundCenSe randomly crashes while I play. I later found out that it consistently crashes whenever I use scripts that rapidly generate a lot of sounds in the log (such as picking up and dropping items).

If the sound queue gets too backed up with something along the lines of 200 or so sounds waiting to be played then SoundCenSe crashes. This limit won't really be reached in normal gameplay (unless an absurdly large fortress has a tantrum spiral), but it leads to problems when running scripts.

I tried this again with the original soundsense and it doesn't crash, but it spends a lot of CPU trying to play 50+ sounds / second)

carterscottm commented 5 years ago

I have found this to be the case for me as well on Linux. I don't use any custom scripts, but found it to happen most often when my military is sparring or defending against a seige.

I had to build 1.4.4 from source on Linux (Debian Buster) as the precompiled version complained about missing .dll files. If it makes a difference, I used nuget to download the latest versions of NLog and NetwtonSoft and renamed the package directories to match the names hinted at in the error messages in the msbuild output.

Algorithman commented 5 years ago

Yeah, sparring and other sounds which occur in one channel over the concurrency limit tend to crash it even it does normally just discard the additional sound effects. I couldn't find the bug though.

@carterscottm Newer NLog/Json libraries shouldn't affect it, they're just used for reading/storing config and the log of course.

Sadly i don't have the xamarin setup running anymore, So i can't really work on it right now.

carterscottm commented 5 years ago

No worries, I'm sure you're a busy person. I know how that goes. I thought I'd do some debugging on my own and let you know what I found. As mentioned above, I compiled a debug build of 1.4.4 from source in Debian Buster using msbuild. The only changes I made are the versions of NLog and Newtonsoft.Json, and I turned on trace messages in NLog.config

It seems that almost every sound played causes FMOD to produce "ERR_INVALID_HANDLE" errors, even when DF and SoundCenSe are first launched.

The exact error I get is:

2018-11-14 09:05:44.4917 INFO FMOD Error: ERR_INVALID_HANDLE 2018-11-14 09:05:44.4917 INFO at SoundCenSeGTK.FmodSystem.ERRCHECK (FMOD.RESULT result) [0x00000] in <ed7a9ee608934dff8a065506f5f13ed7>:0 at SoundCenSeGTK.fmodChannelSound.Stop () [0x00000] in <ed7a9ee608934dff8a065506f5f13ed7>:0 at SoundCenSeGTK.fmodChannelSound.Dispose (System.Boolean disposing) [0x00000] in <ed7a9ee608934dff8a065506f5f13ed7>:0 at SoundCenSeGTK.fmodChannelSound.Dispose () [0x00000] in <ed7a9ee608934dff8a065506f5f13ed7>:0 at SoundCenSeGTK.fmodPlayer.SoundFinished (System.Object sender, Misc.SoundFinishedEventArgs soundFinishedEventArgs) [0x00000] in <ed7a9ee608934dff8a065506f5f13ed7>:0 at SoundCenSeGTK.fmodChannelSound.OnSoundEnded () [0x00000] in <ed7a9ee608934dff8a065506f5f13ed7>:0 at SoundCenSeGTK.fmodChannelSound.<Callback>b__33_0 (System.Object <p0>, System.EventArgs <p1>) [0x00000] in <ed7a9ee608934dff8a065506f5f13ed7>:0 at Gtk.Application+InvokeCB.Invoke () [0x00000] in <7aab76e87bce48a4b45cf7fa613cb70c>:0 at GLib.Timeout+TimeoutProxy.Invoke (System.IntPtr data) [0x00000] in <ed39f21b9e9343dcbd442a17ad356a9f>:0 at GLib.SourceProxy.HandlerInternal (System.IntPtr data) [0x00000] in <ed39f21b9e9343dcbd442a17ad356a9f>:0 at Gtk.Application.gtk_main () [0x00000] in <7aab76e87bce48a4b45cf7fa613cb70c>:0 at Gtk.Application.Run () [0x00000] in <7aab76e87bce48a4b45cf7fa613cb70c>:0 at SoundCenSeGTK.MainClass.Main (System.String[] args) [0x00000] in <ed7a9ee608934dff8a065506f5f13ed7>:0

That message may be tough to read in the confines of this conversation, so I've uploaded the complete log for your review if/when you have a moment. This log file is just running SoundCenSe, waiting a few seconds, and then launching DF.

I browsed through the source myself but am not at all familiar with FMod, let alone C#.

Thank you for writing this utility by the way, I couldn't play DF without it!

2018-11-14.log