AudioSource CPU Usage Even When Not Playing Clip!!!

5.2.2fa
I made a post here (Frame Rate/CPU: Efficiency Tips & Suggestions for Players & Unity - Unity Engine - Unity Discussions), but also thought I would post under the Audio forums.

At this point AudioSource is the biggest contributor to CPU usage and frame-rate reduction in my game.

The AudioSource uses up massive CPU power as long as it is enabled even if it’s not playing a clip!!!
-Muting the AudioSource does not help
-Setting AudioSource volume to 0 does not help
-Having AudioSource falloff set volume to zero (because you are very far away) does not help
-AudioSource.Stop() does not help
-AudioSource.Pause() does not help

The only 2 ways I’ve found to prevent AudioSource from hogging processing power
-Disable
-Destroy

To replicate the issue where AudioSources are chewing up CPU (even if not playing a clip, or volume is 0) create a new blank scene and add this script to an object. For me the FPS is :
0 Audio Sources: 167FPS
200 Audio Sources: 64FPS
400 Audio Sources: 36FPS

using UnityEngine;
using System.Collections;

public class TestAddAudioSource : MonoBehaviour
{
    public int counter;

    private void OnGUI()
    {
        GUI.Label(new Rect(200, 4, 300, 20), "Frame Rate = " + (1f/Time.deltaTime).ToString("0"));
        GUI.Label(new Rect(200, 24*1, 300, 20), "Counter = " + counter.ToString());
        if (GUI.Button(new Rect(200, 24*2, 300, 20), "Add 200"))
        {
            for (int i = 0; i < 200; i++)
            {
                counter++;
                gameObject.AddComponent<AudioSource>();
            }
        }
    }
}

Is anybody else having this problem? I’d like to know suggestions on the best way to get around this issue. Thanks in advance.

Edit: Seems only occur in the Editor, and not within an actual build file.

Using Unity 5.3.3f1 I can see this problem even in build not just in the Editor.

Did you send a bug report to Unity?
Please post the bug number if it is public - I’d like to vote on it. :slight_smile:

Does this only happen when you have an Audio Clip assigned? What about if you set “preload audio data” to false on the clip?

What platform are you running on?

Actually, it’s not that it’s running in the Editor that slows it down. Not exactly. It’s when you have the game object selected and the Inspector with 200+ Audio Sources needs to display that slows it down. If you have any other game object selected (or none), this doesn’t happen.

This is normal and happens with any really large Inspector.