steam-audio icon indicating copy to clipboard operation
steam-audio copied to clipboard

Unity - SetSpatializerFloat is a consistent source of crashing

Open CodeHatchling opened this issue 2 years ago • 15 comments

I've still noticed crashes after the 4.0.2 patch was released. They were a lot more infrequent, but they're still there - in both builds and the editor. A sore spot seems to be switching levels. There's a much higher chance of a crash occurring there. Perhaps SteamAudio classes are initializing themselves in an unexpected order? Perhaps they are being used before being initialized, or before other classes they depend on are initialized?

Here are crash logs I recovered for the editor in which Steam Audio was the cause: crash.zip crash2.zip

Current unity version: 2021.3.1f1 Current steam audio version: 4.0.2

The changes from 4.0.2 to 4.0.3 don't seem to contain anything that'd address this crash; changes are to:

  • README.md - Version bump.
  • CMakeLists.txt - Android-specific compiler arguments added, version bump.
  • build.py - Android-specific cmake arguments added.
  • phonon_version.h - Version bump.

(Though "Performance improvement in Ambisonics Panning/Decode Effect" doesn't appear in the diffs either.)

See this bug report for more details others have reported: https://github.com/ValveSoftware/steam-audio/issues/169

CodeHatchling avatar May 19 '22 11:05 CodeHatchling

Since getting a repro project seems to be difficult according to other users who have reported this issue, an alternative might be to create a branch where checks occur in the crashy spot, and then diagnostic information is provided when those checks detect something?

At the very least, a version with checks to prevent crashes would be preferred, even if there's some overhead involved.

CodeHatchling avatar May 19 '22 12:05 CodeHatchling

The crash occurs when the RAM is full, most likely when the swap is activated

DenisSulyagin avatar May 19 '22 16:05 DenisSulyagin

The crash occurs when the RAM is full, most likely when the swap is activated

Unlikely. I have 64 GB of RAM on my machine. 😎

CodeHatchling avatar May 19 '22 17:05 CodeHatchling

For the sake of organization, I'll link the other two recently reported bugs that seem to deal with the same problem: https://github.com/ValveSoftware/steam-audio/issues/189 https://github.com/ValveSoftware/steam-audio/issues/185

CodeHatchling avatar May 20 '22 11:05 CodeHatchling

The crash occurs when the RAM is full, most likely when the swap is activated

Unlikely. I have 64 GB of RAM on my machine. 😎

Do you have confidence that the memory did not run out at the time of the crash? There is a memory leak in Steam Audio and I can even play it.

DenisSulyagin avatar May 20 '22 12:05 DenisSulyagin

Do you have confidence that the memory did not run out at the time of the crash? There is a memory leak in Steam Audio and I can even play it.

I currently pool most of the audio sources, and the pool is created at level start - which is when it sometimes crashes. BUT, it happens very early on, the first couple of level switches, so it is unlikely RAM ran out already. Plus, my computer runs like crap when the RAM runs out, and it is very noticeable when it happens (and I didn't notice it during the last crash); one of our devs is currently looking into memory without reporting dozens of GB of memory being taken up.

That being said, I'll keep an eye on RAM usage, but I doubt it is the cause.

Good find on the memory leak though. It is likely a problem we'd have to deal with anyway!

CodeHatchling avatar May 20 '22 15:05 CodeHatchling

Replying to https://github.com/ValveSoftware/steam-audio/issues/198#issuecomment-1133063993

https://github.com/ValveSoftware/steam-audio/issues/199

DenisSulyagin avatar May 20 '22 16:05 DenisSulyagin

I can confirm that the cause of the last crash wasn't due to out-of-memory, as I had more than half of my RAM available when it happened.

CodeHatchling avatar May 20 '22 18:05 CodeHatchling

I've removed ALL instances of SteamAudioSource from our project. This seems to fix the crashing while still allowing audio sources to have ambisonic/holophonic spatialization. This obviously means certain features will not work, sadly.

Strangely though, after playing for a while, sometimes the audio will just stop. No sound. Until you restart the app. Better than crashing.

CodeHatchling avatar May 22 '22 17:05 CodeHatchling

I've removed ALL instances of SteamAudioSource from our project. This seems to fix the crashing while still allowing audio sources to have ambisonic/holophonic spatialization. This obviously means certain features will not work, sadly.

Strangely though, after playing for a while, sometimes the audio will just stop. No sound. Until you restart the app. Better than crashing.

you can try to just comment out the lines from https://github.com/ValveSoftware/steam-audio/issues/199. and return some functions

DenisSulyagin avatar May 22 '22 17:05 DenisSulyagin

you can try to just comment out the lines from #199. and return some functions

I'll try it at some point. Currently, we can't afford to have any crashes and this plugin just smells of bad null-checking coding hygeine - but it is an advertised feature, so we can't just remove it either.

CodeHatchling avatar May 22 '22 17:05 CodeHatchling

I've removed ALL instances of SteamAudioSource from our project. This seems to fix the crashing while still allowing audio sources to have ambisonic/holophonic spatialization. This obviously means certain features will not work, sadly. Strangely though, after playing for a while, sometimes the audio will just stop. No sound. Until you restart the app. Better than crashing.

you can try to just comment out the lines from #199. and return some functions

Sorry, just to clarify, what do you mean by return some functions? I've been struggling with this error myself, and am not sure how to fix the issue with the memory allocation.

gamesfortourists avatar Jun 12 '22 20:06 gamesfortourists

I've removed ALL instances of SteamAudioSource from our project. This seems to fix the crashing while still allowing audio sources to have ambisonic/holophonic spatialization. This obviously means certain features will not work, sadly. Strangely though, after playing for a while, sometimes the audio will just stop. No sound. Until you restart the app. Better than crashing.

you can try to just comment out the lines from #199. and return some functions

Sorry, just to clarify, what do you mean by return some functions? I've been struggling with this error myself, and am not sure how to fix the issue with the memory allocation.

a memory leak occurs in the reflection property. all other properties like occlusion, spatial, binaural, etc. will work correctly

DenisSulyagin avatar Jun 14 '22 08:06 DenisSulyagin

We've just released Steam Audio 4.1.0, which includes various crash fixes: https://github.com/ValveSoftware/steam-audio/releases/tag/v4.1.0.

Try it out and let us know if these crashes persist in the new version.

lakulish avatar Jul 05 '22 20:07 lakulish

We've just released Steam Audio 4.1.0, which includes various crash fixes: https://github.com/ValveSoftware/steam-audio/releases/tag/v4.1.0.

Try it out and let us know if these crashes persist in the new version.

the problem exists

DenisSulyagin avatar Jul 06 '22 13:07 DenisSulyagin

We've just released Steam Audio 4.1.2, which contains a potential fix for this issue: https://github.com/ValveSoftware/steam-audio/releases/tag/v4.1.2. Try it out, and let us know if the issue persists.

lakulish avatar Nov 23 '22 23:11 lakulish

Closing pending feedback.

kisak-valve avatar Dec 30 '22 20:12 kisak-valve