Search Issue Tracker

In Progress

Under Consideration for 2021.3.X, 2022.3.X

Votes

0

Found in

2021.3.34f1

2022.3.20f1

2023.2.9f1

2023.3.0b5

6000.0.0b11

Issue ID

UUM-61733

Regression

No

[Crash] Adding AudioListener component with OnAudioFilterRead crashes the editor

--

-

When removing the audio listener on a game object and adding it back, it crashes the editor if the game object has a script with OnAudioFilterRead attached to it.

*Repro*
# Download the attached `OAFR.cs` script.
# Create and open an empty project.
# Import the `OAFR.cs` script.
# In the SampleScene, add the OAFR component to Main Camera.
# Remove the audio listener component.
# Add an audio listener component.
# If the editor does not crash, do the following:
## Remove the OAFR component.
## Repeat steps 4-7

Expected: No error is thrown in the console and the editor does not crash

Actual: An error might be thrown in the console and sometimes the editor crashes.

*Note*

Sometimes the editor doesn't crash but an error is thrown in the console, which might hint at the problem.

*Stack trace (crash)*

See attached `Editor.log`.

*Stack trace (error)*
{code:java}
GameObject has multiple AudioSources and/or AudioListeners attached. While built-in filters like lowpass are instantiated separately, components implementing OnAudioFilterRead may only be used by either one AudioSource or AudioListener at a time.
The reason for this is that any state information used by the callback exists only once in the component, and the source or listener calling it cannot be inferred from the callback.
In this case the OnAudioFilterRead callback of script OAFR was first attached to a component of type AudioListener on the game object  after which another component of type AudioListener tried to attach it.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) {code}

Add comment

Log in to post comment