Search Issue Tracker

By Design

Votes

1

Found in

2019.1.0a9

2019.1.0f2

2019.2.0a1

Issue ID

1147478

Regression

Yes

AudioSource.PlayOneShot doesn't play sounds properly when there are a lot of animated sprites in the scene

Audio

-

Steps to repro:
1. Open original project "Sound_Bug_2019.1.zip"
2. Enter PlayMode and listen to the Audio

Expected result: Audio does not stutter.
Actual result: Audio stutters.

Reproduced in: 2019.1.0f2, 2019.2.0a13
Not reproduced in: 2018.3.14f1, 2019.1.0a8

  1. Resolution Note (2019.3.X):

    This is simply because the large number of game objects causes a long Animators.Update (see Profiler) that ranges from 12-28 ms on a fast computer. Thus frames will be skipped, and there will therefore be less frequent frame updates than the code aims for with it's 20 ms throttling. Both Play and PlayOneShot are equally affected by this, and to make things worse the chosen "Best Performance" setting in the Audio Settings results in the largest DSP buffer used (4x as large as "Best latency"), so that further increases the likeliness of having large gaps between the frame update and the point at which the audio playback event is handled. If you want rock-solid timing of sub-frametime, you need to use PlayScheduled to trigger multiple events to occur during the next frame update, and as an AudioSource can only handle one scheduled playback event at a time, you need to delegate these out to multiple sources (from a pool so they can be reused efficiently).

Comments (1)

  1. arkogelul

    Jun 14, 2019 11:40

    Alright, but what I can see is that, over time, Unity becomes less capable of handling things. In previous versions, Unity was able to handle this (I agree) badly design setup just fine.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.