djpadbit / Sound-Physics

A Minecraft mod that provides realistic sound attenuation, reverberation, and absorption through blocks.
GNU General Public License v3.0
135 stars 19 forks source link

Elytra Crash [1.12] #44

Closed DarianLStephens closed 4 years ago

DarianLStephens commented 4 years ago

I can't be 100% certain, but it seems this mod is causing a crash after you use the Elytra too many times, or perhaps just at random? You also seem to lack the Elytra sound, but perhaps that's due to interference from another mod?

Investigating this crash online, Sound Physics has been the sole mod shared between each report, and so appears to be the most likely cause.

No crash report, unfortunately, as the world simply hangs and saves, then never responds again, forcing me to kill the process (I've left the game running for 5+ minutes after it hanged, and it never recovered).

Apologies if this ends up being a false-positive, but I'm not sure where else to look.

djpadbit commented 4 years ago

Sound Physics doesn't handle moving sounds yet so it's normal that the elytra sound isn't processed. For the hanging, I managed to recreate the problem very easily actually which is quite the problem. From what i'm seeing, it's a deadlock between the chunk renderer threads and the sound system thread (where Sound Physics's on play sound hook is run). They are both stuck on the player's EntityDataManager's read lock inside getEyeHeight because that function checks if the player is in a elytra which is a value stored inside the data manager. But it shouldn't deadlock as they all want to read and not write and a ReentrantReadWriteLock should let them all read fine. This is probably gonna take a bit of time to figure out so i'll try to keep this updated as i'm working on it.

Update: It's playing the elytra sound when updating the data manager so the write lock is held and Sound Physics tries to get a read lock which is what is causing the deadlock. But the problem is why is it trying to evaluate the elytra sound ? I'm guessing the main thread plays a sound which overrides the last sound info in Sound Physics and it thinks it's a sound it should process

Update 2: Actually it's deadlocked when sending the new source command for the elytra to the sound system when it's processing a normal sound playing. So the data manager is locked and it waits for the sound system to finish the play sound command but inside, Sound Physics tries to read the data manager's value and ends up in a deadlock with both theads waiting for each other.

djpadbit commented 4 years ago

It should be fixed now. Since it's a pretty important bug, i made a patch release that you can download here.