henkelmax / sound-physics-remastered

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

Waterfall sound (from Effective) calculations causes lag spikes #29

Closed egeesin closed 2 years ago

egeesin commented 2 years ago

Bug description It seems there's a performance issue with Effective and SPR. As far as I observed, there's falling water layer under the sea causes hundreds of calculations made by SPR and creates lag spikes with small periods if the waterfall sound source is in the simulation distance. But if waterfall itself exposed to air as intended, it doesn't lag.

In the upstream repository there's also similar issue. I tested same seed and location with SP v0.5.4 (vlad2305m) enabled and the graph is identical. There's a comparison in the screenshots section.

Steps to reproduce the issue

  1. Create a Creative world (Cheats On) with seed -3928481868936690376
  2. Execute /tp 251.8 66 -107
  3. Listen and observe waterfall sound source directly beneath. (If there's not sound, tinker with simulation distance and or try to break the sand blocks next to falling water.
  4. Alt+F3 to observe lag spikes. 4.1 Go to SPR config and enable Performance logging. 4.2 Check log.

Expected behavior Calculating (or not calculating) waterfall sounds without causing lag spikes in the generated environments like mentioned above.

Log files Summary:

...(thousands of same line)
[23:39:14] [Sound engine/INFO]: Total calculation time for sound ambience.waterfall: 0.0022 milliseconds
[23:39:14] [Sound engine/INFO]: Total calculation time for sound ambience.waterfall: 0.0021 milliseconds
[23:39:14] [Sound engine/INFO]: Total calculation time for sound ambience.waterfall: 0.0021 milliseconds
[23:39:14] [Sound engine/INFO]: Total calculation time for sound ambience.waterfall: 0.0021 milliseconds
...(thousands of same line)

latest.log

Versions

Other mods

Extra Temporary workarounds are adding "waterfall" to the regex blacklist like this: .*(rain|waterfall).*, muting ambient sounds completely in the vanilla settings or disabling SPR.

Screenshots (Optional) 2022-01-21_01 23 12 2022-01-21_01 23 26

if waterfall itself exposed to air as intended, it doesn't lag 2022-01-21_01 24 03 Same location and seed, different fork (vlad2305m) 2022-01-22_16 10 21

Related https://github.com/Ladysnake/Effective/issues/10 https://github.com/vlad2305m/Sound-Physics-Fabric/issues/39

henkelmax commented 2 years ago

As they already said: https://github.com/vlad2305m/Sound-Physics-Fabric/issues/39#issuecomment-995251526

It is an issue by the mod spamming the sound. There is nothing that can be done on the sound physics side, except completely blacklisting the sound.