Audio crackling (desktop)

https://streamable.com/aqn0a4

I was sent this video by a player. There is an annoying crackle in the audio that wasn’t present before (most audible at about 15 seconds onwards). It’s a bit subtle so you might need to turn up your volume to hear it, but once you hear it it gets really annoying.

I hadn’t noticed it myself, but launching the build on my own computer I was able to verify that I can hear it too (albeit slightly less).

Build history:

Aug 11th (1.2.171) - No crackle :green_heart:
Sep 4th (1.2.172) - Crackle :broken_heart:
Today (1.2.173) - Crackle :broken_heart:
Today (reverted to 1.2.171) - No crackle :green_heart:

Could it have something to do with the below fix? It was added in 1.2.172 which was the first time this appeared.
Issue-4837 - Fixed : Sound is now run on a separate thread

3 Likes

You should add https://github.com/britzl/defold-metrics if you don’t already and see what the update rate is at. I suspect something related to that could be causing the issue if it’s not at 16ms / 60FPS. But I have not read the current audio source and don’t know how it actually works.

I have heard occasional minor crackling in our projects too since 1.2.172, often still when switching scenes, but overall the audio quality is still much better and more stable than before being on its own thread. With the old audio if you were loading lots of data while playing audio your users probably still heard audio issues even if they did not report them.

It is very possible it’s related to the recent sound threading changes.
We wake the thread every 8ms, to check if there’s any free soundbuffers (there are currently 6 in OpenAL), and fills them all.
This leads be to believe that it’s not really about starvation, but something else. (I can ofc be wrong here).

3 Likes

I don’t have defold-metrics but I enabled my own debugging and can confirm it’s sitting at 60FPS. The video is of the main menu (though it happens in-game too) so I’d be quite upset with myself if that wasn’t 60FPS.

Generally I’m happy with an improvement to the audio system because I was having the same issue as everyone else with stuttering during collection loading. I worked around that by either loading async or quickly fading the music in/out.

I don’t agree that there were audio issues before (in terms of this crackling), though. Not for me, anyway. I can now reliably hear crackling when I sit in the main menu doing nothing. In a 1.2.171 build there’s nothing like that.

While the crackling is subtle, I don’t think it’s subtle enough to be acceptable for me. So for Fates of Ort I’ll have to stick with 1.2.171 until (?) it’s fixed.

2 Likes

Can you confirm how your version of getting FPS data works? It’s using socket.gettime() and not dt?

The audio issues generally depend on the device, it’s why they are hard to debug. Newer computers would rarely hear the same kinds of issues builds from 10 years ago would.

2 Likes

I use both types!

1 Like

The easy option would be to add a game setting to disable the sound thread (which we might do). But I’d rather actually fix the issue. Perhaps you could provide a small repro for this?

3 Likes

It would be useful to know as close to exact system information for the computers where you hear the crackling. OS version, GPU, and CPU most important.

Is there a version of the game on a beta build with 1.2.173 I can test to record?

1 Like

My first test was to create a blank project with nothing else in it other than the music. There’s no crackling there, which I’d say is definitely a good thing.

I then took my main project and tried to strip it down as much as possible. I got it down from 400mb to 145mb. It would probably be possible to strip it down further, but so much breaks as you delete things that it gets to be a pain.

I then recorded a test video of the main menu, in 1.2.173 and 1.2.171. I let it play normally for about 40 seconds to hear crackling when nothing is happening at ~60 fps. I then intentionally wreck the fps (by launching another instance of Defold) to hear what that does. The result is that 1.2.173 has some stuttering (very minor, but still) at 60fps, but 1.2.171 does not. Both get completely ruined by a large drop in fps, but that’s probably not surprising.

:warning: The sound in the recordings is quite low, that’s my bad. I suggest you wait until the music starts playing, then turn up your volume so the sound is quite loud. Since the stutter is quite subtle in my tests you do need it quite loud.


1.2.173

00:32 - you will hear a skip at 00:33 and 00:37
00:50 - around this point I intentionally wreck the fps


1.2.171

00:45 - no skips until this point, when I intentionally wreck the fps


My results for 1.2.173 are much subtler than those of the person who reported the issue to me, so it seems like @Pkeod’s suggestion that it’s device dependent seems reasonable.

My specs: DxDiag.txt (125.1 KB)

Specs of initial report: DxDiag_reporter.txt (87.2 KB)

I can provide a copy of this scaled back test version, if that’s easiest?
Edit: Scaled back test here

1 Like

I’ve added issue 5245 for a workaround, being able to disable the sound threading. SHould land in 1.2.175.

2 Likes

Nice! That will be useful for now. Are there any thoughts on a fix for the skipping in threaded sound? Or is it the expected outcome?

We just haven’t had time to investigate the issue thoroughly, so this is just a workaround in the meantime.

2 Likes