Sounds, CPU and everything inbetween.
Here’s something you Unity developers should know when developing for mobile or low end devices.
Sounds can kill!
Well actually they won’t but they can have you chasing your tail for a while and a half! You see the Unity profiler has a CPU section which is great for finding out what’s taking up all the precious CPU time right? Well… not always. Unity on the iPhone uses the Apple sound decoder which is great because it’s faster/better, sadly it does not show up in the CPU profiler. Instead the only indication of its expense is in the Audio profiler.
This may not seem like a big deal but the real problem is that when the audio thread is decoding lots of sounds at once it starves the main thread of time and what’s really bad is this appears in the CPU profiler as random spikes in random functions throughout your program. This is a big gotchya!I was scratching my head trying to figure out why functions with almost nothing in them were taking 20 milliseconds. It got to the point where I was trying random things like reducing the total number of objects in the scene, killing specific effects and assets and it was all in vain.
So just a word of warning to you all when you add your sound effects to Unity. Make sure they are set to ‘Decompress on load‘. This may give you a few more MBs of memory usage but it’s worth it as any other setting will cost you about 5-10% CPU per sound playing.

