AmbientSounds 5

AmbientSounds 5

39M Downloads

sound system crash

0Navis0 opened this issue ยท 125 comments

commented

When I load a world, I get a message of the chat that the sound system crashed and try to restart it when the first chunks of the world load them. Then the game freezes and crashes, I get this crash report https://pastebin.com/ENRx0Sn7.

commented

Okay it seems the crash doesn't occur more, I don't know what caused it, anyway I close it for the time.

commented

Okay the problem still happens sometimes >___<

commented

no it still happens, i will try to reproduce it with debugging mode. i hope it's foamfix.

commented

I could not reproduce this issue. So it's not caused by the forge version, FoamFix or any of my mods. It would be really hopefully if you could try to find out which mod causes this issue.

commented

Either you try to find the conflicting mod yourself or you can send me your mod and config folder so i can do it myself.

commented

https://www.technicpack.net/modpack/magenjia.1010676
Here is my modpack. Hope it helps... or tell me if i should find conflicting mod, but it will take years for me i think. But i can tell some mods that tweaks sound system:
Mxtune, dynamic surroundings, mobends

commented

hello, i reproducet it on debugging mode. here is the crash report:
crash-2017-05-29_11.41.52-client.txt
and here is the logs:
fml-client-1.log.txt
fml-client-latest.log.txt
latest.log.txt
hope these help. thanks.
BY THE WAY, what happened last time before sound system crash:
in-game music just stopped suddenly, i waited it to start again, but it didn't start, SS crashed.

commented

Same crash?

commented

Yes :(

commented

It is surely caused by Dynamic Surroundings, the problem doesn't seem to occur more without it.

commented

cool. hope it will be fixed.. @OreCruncher may look it :D

commented

Fix what? A crashed sound system? The stream handling thread in PauslCode (the underlying sound engine library) can crash, hard. The logic in Dynamic Surroundings detects the dead thread in PaulsCode and automatically re-initializes the Minecraft sound engine. IIRC there are some is a keyboard shortcut in Minecraft that can do this as well - just don't recall what it is.

You can turn this ability in Dynamic Surroundings OFF in the later BETA builds. It will still give you a chat notification that the engine died. The symptom of a dead sound engine is that no streaming sound will play.

commented

hey, i see something like "sound system crashed, restarting it..." on the chat JUST before this crash happens. what does it mean?

commented

It means that Dynamic Surroundings detected that the streaming sound handling thread in PaulsCode died and it tells the Minecraft SoundManager to do a reloadSoundSystem(). I think it is the reload that is causing Ambient Sounds the problem.

commented

hmmm. but it's just a reload, if we disable it; shouldn't it be crash anyway?

commented

The streaming thread will crash, Minecraft will not.

commented

hmmm... i see. so we can't disable sound system reloading feature in DS, right?
in fact, instead of adding option to disable this feature, can't you improve it as doesn't cause this crash?
well, it's up to you, i'm just giving suggestion to help as much as i can to development of the mods :b

commented

so you know what u should do. i'm just a tester :D

commented

I think this might be the issue here. Is there an event or something like that?

commented

No, you CAN disable the auto-reload feature of Dynamic Surroundings. Option should be in the latest BETA. It will still give you a chat message indicating that the thread died so you can restart the client.

commented

Forge posts a SoundLoadEvent as the last thing it does in the reloadSoundSystem().

commented

Thanks for quick help, this should fix it:
https://www.dropbox.com/s/tbap8ieg0jkzfzs/AmbientSounds%20v2.0.2%20mc1.11.2.zip?dl=1

Will release once it's confirmed.

commented

oh... how fast... thank you creativemd, and thank you orecruncher. i'm very happy now to use both mods with no pain :d

commented

@OreCruncher pretty cool idea, since the sound system crashes rather often.

commented

lol - yeah. Since 1.7.10 I been wondering why my streaming sounds just stopped for no apparent reason. I eventually caught it in a debugger, spent 5 minutes cursing, then went about "fixing" it.

commented

by the way, i just wanted to mention my second comment on this issue (#7 (comment))
it(ingame music stops suddenly sometimes) was happening for a too long time before, i can't even remember.
edit: so, it was a sound system crash in ambient sounds, as i understood. so i just wanted to ask it, shouldn't it be fixed as an issue?

commented

But also the SoundManger causes a lot of issues. It uses a HashBiMap so there are two connected maps which contain all sounds (HashMap<String,ISound> and reversed HashMap<ISound,String). The problem is that they will not be synchronized immediately. So if you play a sound and check one tick later if it is playing or not it will (most likely) return false.
There used to be a bug in the old AmbientSounds that if you would leave a biome and enter it again within a few seconds, games with low fps crashed, since the sound was still in the second hashmap (throwing a duplicate exception). It took me until now to find out what is causing this issue, so i just write my own soundmanager :D

commented

sounds amazing :D get luck with

commented

I get another crash with the new version https://pastebin.com/bG7RUh3N

commented

Could you try to redownload it (it should be fixed now).

commented

It still doesn't work. :(

commented

hey ah, i just disabled sound system reload feature in DS as @OreCruncher said, then i played about 1 hour; and sound system has been crashed about 20 times, and at the last; minecraft crashed. :(

commented

I could not reproduce this issue with only AmbientSounds and DS installed using AmbientSounds v2.0.2, no idea why it crashes for you, i will now try to download to modpack and to some testing with all the other mods installed as well.

commented

hmm, you can download my modpack if you want, sound system reload feature disabled in the latest version. thanks a lot. hope it be fixed :(

commented

I would try it with kenijey's pack. In my experience the sound system crash is related to client lag, and some modpacks are worse than others.

commented

Ok i did some testing, running the game with decent 15 FPS, but no crash or what so ever. This version will fix the crash, but since i don't really know what is causing this issue. So AmbientSounds might be quiet once it will happen again:
https://www.dropbox.com/s/tbap8ieg0jkzfzs/AmbientSounds%20v2.0.2%20mc1.11.2.zip?dl=1

commented

hope it fixes it... thanks.

commented

The crash still occurs for me. :( https://pastebin.com/Gc1MWD6W

commented

@Hypsellis you are crash are really weird and don't make sense at all. When does it happen? During loading the world? Randomly while playing?

commented

hey everyone, ah; i dedicated the crash. mxTune mod causes this shit. i deleted it, no sound system crashes anymore. just wanted to let you know

commented

For me it's not caused by MxTunes since I never downloaded it. I haven't any ideas what cause it, anyway it happens randomly while playing.

commented

Actually only a thread could cause issues like that, but it is not threaded. As i said already, that crash doesn't make any sense, but maybe this version fixes it:
https://www.dropbox.com/s/hlyz5o7jei4hzti/AmbientSounds%20v2.0.3%20mc1.11.2.zip?dl=1
It would be really helpful if you could take a look at the log afterwards and see if AmbientSounds is logging anything suspicious.

commented

ahhhhh, yes; it crashed again without mxTune too. i really don't understand what's going on, but it crashed without ambinet sounds too. dunno what causes...

commented

but, it crashed after playing 6 hours.

commented

crash-report? using v2.0.3?

commented

i just installed it, i will when it crashed. thanks.

commented

Damn I still get the same crash. :(

commented

This cannot be the same crash, could please send me the log every time? Since i have updated the code, at least the line number should change, furthermore i have implement a non null check, so you should see something in the log. So it would be really good if you could provide me your whole log.

commented

Here is the crash report. https://pastebin.com/wwQE54i2

commented

Ok ... could one of you test this issue with only AmbientSounds installed. It would be very helpful to know if this is an issue caused by a mod or not. As I said before this crash is actually impossible to happen without threads.

commented

as i said, it will take years to find which mod causes :D because it happens very random.

commented

hey ah, here is another crash with 2.0.3 AS
crash-2017-06-03_15.22.43-client.txt

commented

and what is paulscode in the crash?

commented

hey @Hypsellis , which mods you are using?

commented

@kenijey PaulsCode is the underlying sound engine in Minecraft.

commented

oh sry i remember it now
i saw it before on eclipse in forge directory

commented

I use so many mods in same time, it would take a lot of time before to know which one specifically cause this crash. :(

commented

Just run it without any other mods, i just need to know if a mod is causing it or not.

commented

It doesn't crash without other mods.

commented

@CreativeMD Does your sound engine run in the client thread, or separate thread?

commented

OK. A possibility is that if you are listening for the SoundLoadEvent the underlying sound system may not be fully initialized. loadSoundSystem() spins off a thread to the init, and that routine is what creates the various threads in PaulsCode. (PauslCode does a lot of init in it's SoundSystem CTOR which generally is not good OOP practice.) Anyways, you may want to check the "isLoaded" flag of the Minecraft SoundManager, or at the top of your tick() routine check that system is not null. This may solve it for you.

commented

Thanks, but this solves the AmbientSoundEngine crash, but actually it's about the TickHandler what is crashing without any particular reason.

commented

You mean this one from Hypsellis's report?

EDIT: If it is, then I recommended looking at your world unload handler. Make sure you are checking whether it is remote or not. My theory is that the server thread is unloading a world, the handler gets invoked, which in turn yanks the "situation" out from under the client thread.

commented

Oh good idea, that might causes this issue, especially if you have dimensional mods installed. Hopefully it will work now:
https://www.dropbox.com/s/hlyz5o7jei4hzti/AmbientSounds%20v2.0.3%20mc1.11.2.zip?dl=1

commented

what if sound system crashes (only ss, not mc) without ambient sounds? :D (very rare)

commented

Generally mods don't notice. If this sound system crash were to occur the only thing a player will notice is that streaming sounds (like music) will stop playing. Mods like Dynamic Surroundings have many more streaming sounds and it becomes noticeable. The reason I put this restart in was because players were starting to point the finger at DS for the problem when the reality was that PaulsCode is pretty fragile and does not handle IO errors gracefully.

commented

Yes indeed, it was also a problem of AmbientSounds too, maybe some asm transforming could fix it? I might take a look into that.

commented

Would be nice if you could work it out. Other possibility is to wrap the underlying URL stream so it detects error conditions and closes off the stream cleanly. This may cause PaulsCode to choke if an OGG stream reaches EOS when it is expecting more data - but it would be interesting to see what happens.

commented

@Hypsellis @kenijey Could you try out a test Dynamic Surroundings located here? It has some prototype code that does the following:

  • Caches sounds that are < 64K in length. This is to improve overall handling of frequently played small sound clips.
  • Wraps the sound resource from the JAR so that if there is an error it attempts graceful handling.

@CreativeMD If you want to take a look at the code you can find that here. I use ASM to hook the SoundManager.getURLForSoundResource and redirect it to my own implementation in SoundCache.getURLForSoundResource.

commented

It seems to work now, I don't get more crash.

commented

It seems I don't get more the crash, at least for the time. I noticed another minor issue. Underground sounds play them when the sky is partially covered by blocks, I suppose the sound event depends of the level of natural light. The problem is the underground sounds play them in huge forest with many trees covering the the sky, typically some BOP biomes.

commented

Okay I just got the crash again, but this time it's sighly different, it looks like the first ones I got. It crashed just after the sound system crash and try to restart. https://pastebin.com/bqBDmVrh

commented

@Hypsellis Have you tried it with the Dynamic Surroundings v3.4.5.3 Test version? The crash indicates you were using the v3.4.5.2 version.

commented

No I didn't try it yet, I'm currently trying it now.

commented

I didn't get crash yet with this version, I don't know if the problem is solved.

commented

I just got a crash again, but this time it toke many time before it crashes, it seems to happen rarely now. It seems the crash happens when I move quickly between biomes and the sounds change, the sounds system crashes and tries to restart, and then Minecraft crashes. https://pastebin.com/t6AmNR4B

commented

this crash happens without ambient sounds too. yes, it's very rare and i couldn't find which mod causes.

commented

Okay, sorry that i couldn't respond the last 2 days, but now i will try to fix it.

The situation
The paulscode engine crashes randomly, while trying to play a streaming sounds. DS has implemented a feature which reloads the engine once it has crashed. AmbientSounds is not prepared for it, meaning crashes can occur during reloading the sound engine. Although they are rather unlikely if you play for a while it will eventually happen (as far as i can tell).

Ways to solve this

  • I could prepare AmbientSounds to be aware of reloading the sound engine at any point
  • I could try to fix the bug which causes the engine to crash in the first place.

What i'm trying
So i tried to fix the crash of the paulscode engine. The new version of AmbientSounds released on curseforge could do so, but unfortunately it is not tested as i couldn't reproduce the crash of the engine. It would be very helpful if you could test it out for me. @OreCruncher Does DS log the crash of the sound engine (it would help to see if it is fixed or not)? If the game crashes or all sounds stop (engine crashes), please also provide the full log of your game.

@OreCruncher
AmbientSounds overwrites the OggDecoder with a "fixed" version of it. Actually i just add a try and catch to the readBytes() method as the decoder seems to be implemented correctly (following the tutorials of the JCraft website): https://github.com/CreativeMD/AmbientSounds/blob/1.11/src/main/java/com/creativemd/ambientsounds/CodecJOrbisFixed.java#L623

If the issue is more complicated to solve, i will prepare AmbientSounds to not crash if the DS is reloading the engine.

commented

@CreativeMD Yes, warning information is put into the client log file when the sound engine gets restarted. Look for the text "It looks like the sound system has crashed". As for the fix I am not too familiar with the code. One thing that I do wonder about is whether you need to set end of stream to TRUE and cause the entire sound play to be aborted.

commented

@OreCruncher oh yes, might be a good idea to add this as well, but first i will wait if this fix causes anything else to crash.

commented

Any crashes so far? Has someone tested it already?

commented

I abandoned my modpack. I will build a new modpack in 1.12. We will test it together :) so don't forget to update your mods when forge released, creativemd :D

commented

I got a crash with the latest versions of AmbientSound and DynamicSurroundings from Curse, v2.0.3 and 3.4.5.3 respectively.
I also have SoundFilters-0.9 in the pack, which could mess with the sound system.

Forge: 13.20.0.2314 (on both server and client)
Right now, I'm playing on a server, but at least the sound engine also crashed in single player.

https://gist.github.com/tyra314/9f73e4c958cea26ea370c9390964ba4c

commented

Could you please send me your complete log file? It allows me to find out whether the sound engine crashed or not.

commented

I got this crash with the last Ambient Sounds and Dynamic Surroundings versions. https://pastebin.com/TTGysJMW

commented

Sorry, it's already gone. I'll make sure to send you both next time it happens.
But I could see the chat text about restarted sound engine and a second later my whole client crashed.

commented

Please i need the whole log, which can be found in the logs folder. The old once will be archived so you should be able to find those too. I need those logs otherwise i can't find out why the engine has crashed. The crash-reports don't really matter at the moment.

commented

I don't have it more, I will give you it when I will get the crash again.

commented

It just happend once more. Here a gist with both, crash report and log file:

https://gist.github.com/tyra314/209e9ecef27e43d325e103708af5242d

commented

Is it the full log file? Because it does not even cover the whole startup process :(

commented

It's not the good log, I will post it when I will get the crash again.

commented

@CreativeMD I did manage to catch the crash in a debugger. Here is a snip of the stack trace of what I saw:

[14:23:00] [Thread-26/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: java.lang.NullPointerException
[14:23:00] [Thread-26/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: 	at paulscode.sound.codecs.CodecJOrbis.readBytes(CodecJOrbis.java:587)
[14:23:00] [Thread-26/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: 	at paulscode.sound.codecs.CodecJOrbis.read(CodecJOrbis.java:356)
[14:23:00] [Thread-26/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: 	at paulscode.sound.Source.stream(Source.java:953)
[14:23:00] [Thread-26/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: 	at paulscode.sound.StreamThread.run(StreamThread.java:129)

The null pointer it is referring to is the codec for the sound stream. It is null. What I saw in the debugger was that the IO stream for the sound resource was closed when PaulsCode was trying to read it. The null pointer and the closed stream tells me that something in PaulsCode closed out the sound source (closed the stream and disposed of the codec) out from underneath the stream thread. I think the best that can be achieved given this circumstance is to make sure the thread doesn't die and the offending sound source is removed from the internal lists to make sure it doesn't trip over it again.

commented

@OreCruncher ok, but your crash is still really weird. Have you used 1.11.2? Since there can't be a nullpointerexception at this line in 1.11.2.

Actually i don't know too much about this issue. I only knew of its existence before and also reported it to the author (http://www.paulscode.com/forum/index.php?topic=14927.msg29451#msg29451). As you can see it's a different crash:

[17:36:04] [Thread-11/INFO]: [STDERR]: 	at com.jcraft.jogg.StreamState.packetout(StreamState.java:186)
[17:36:04] [Thread-11/INFO]: [STDERR]: 	at paulscode.sound.codecs.CodecJOrbis.readBytes(CodecJOrbis.java:575)
[17:36:04] [Thread-11/INFO]: [STDERR]: 	at paulscode.sound.codecs.CodecJOrbis.read(CodecJOrbis.java:354)
[17:36:04] [Thread-11/INFO]: [STDERR]: 	at paulscode.sound.Source.stream(Source.java:953)
[17:36:04] [Thread-11/INFO]: [STDERR]: 	at paulscode.sound.StreamThread.run(StreamThread.java:129)

It might be a good idea to contact him again, especially if you have collected more information about this issue.

commented

@CreativeMD It is possible my stack is a bit different. Reasons:

  • I have a sound cache. What this cache does is keep OGG sounds < 64K in memory. When a URL is needed for an OGG I look it up in the cache and reuse the data. Underneath it all is a ByteArrayInputStream.
  • For a stream >=64K I wrap the IO stream provided by the resource manager in order to trap streaming errors. When doing my testing I have breakpoints set in this wrapper and the callstack above is from one of those breakpoints. My hope was that the wrapper would prevent the error, but unfortunately the masking caused it to trigger something further down the line.

From what I can see Minecraft is not using the latest version of PaulsCode. I wonder if there is an updated codec that can be installed and used with the installed version.

commented

@OreCruncher okay, i have contacted the author again, maybe he can help us out:
http://www.paulscode.com/forum/index.php?topic=14927.msg30042#msg30042

commented

@OreCruncher It looks like this a weird threading issue, since i had a different crash before.

Did the sound engine crash afterwards? I'm printing the exception just for debugging purpose, theoretically the engine could have survived it: https://github.com/CreativeMD/AmbientSounds/blob/1.11/src/main/java/com/creativemd/ambientsounds/CodecJOrbisFixed.java#L624

Have you used the newest version (v2.0.4)?

commented

@CreativeMD Ah, no. This is with just my mod. I been trying like the dickens to figure out the root cause of why the thread is crashing and managed to collect more data. It's more than I had before; not sure of all the details you have discovered. I am feeling more comfortable that this is a bug with PaulsCode, and the reason it is showing up is because the number of streaming sounds that are being played increases the chance it will be seen.

It also gives me a bit more confidence in the "just trap the error and suppress" approach. It seems that some other thread already performed house cleaning on the sound source state so trying to do extensive cleanup with your patch may not be required.

commented

@OreCruncher The newest AmbientSounds version should end the stream properly, so the sound engine shouldn't crash anymore.

I looked deeper into the code and my guess is, this crash occurs while cleaning up the coded. Either because the engine tries to play a new sound or it cleans up the codec too early. The first case sounds more promising.

My guess
If the engine runs out of streaming channels, it uses an already existing channel to play the new stream (and stops the old one). Maybe those threads are not in sync and therefore will eventually collide. Before the new stream will be played it will clean up everything, if the other thread is streaming at exactly this moment, this crash could occur. It's just an idea, but i will implement some logging, so i might be able to find out if that's the issue or not.

The fixed codec
It might be a good idea if you could use this fixed codec, too. Feel free to use and add it to your repository: https://github.com/CreativeMD/AmbientSounds/blob/1.11/src/main/java/com/creativemd/ambientsounds/CodecJOrbisFixed.java

commented

uhm, we are playing it on 1.12 for a week, and no any sound system crash so far. (using AS 2.0.4)