[SOLVED] Audio glitching out

hello, we have sound glitching out after some amount of play time and we need help. Do you have any known issues/bugs in regards of this?
By glitching out, we mean, that it sometimes starts stuttering without stop and in rare cases even cuts out completely.

Is this on mobile, desktop? Any particular browser version? Do you have an example/minimal project to reproduce? Any errors in the browser console?

It’s a Facebook Instant game;

Here’s the link: http://m.me/804341369630989?game=926615630843478

The audio glitches/errors are not present on desktop, they are common on mobile devices (IOS tends to have those stutters and at least one Android device cuts out the sound every once in a while). To get to those artifacts, you kind of have to be playing for a while though (about 5 or so minutes).

Do you have a version of the game without the Messenger Integration? It should be easier to debug with just the Chrome browser.

Are the audio effects on separate audio sources? (eg is each ball it’s own audio source? Too many sources for the platform?) Are they MP3s/Oggs/Wavs (wondering if you are hitting decoding issues?)

Well, there are only 3 audio sources (one for background, one for all the ball and physics sounds and the third one for menu effects. Nothing else, really).

We did experiment with different audio formats with no difference in results (current active version uses mp3). Also tried to turn all the collision sounds off, leaving just the ones in the menu and when grabbing/throwing /scoring and the same glitches appeared no matter, what.

We don’t see those problems in browser on windows or mac and don’t exactly have an online version apart from the PlayCanvas play mode, which, by the way, has the same errors on mobile browsers as the messenger deployment (project is the same, there are just some occasional unhandled exceptions when ending the game, due to the FbInstant api not being found, but that does not exactly make the thing unplayable).

We can send you the build from Playcanvas if you give us some address to send to.

Just to confirm, you don’t get any errors in the log about audio on the mobile browser when it glitches?

There are no explicit audio playback related errors in the log, however it’s kind of full of “DEPRECATED: pc.GraphNode#_dirtify is deprecated. Use the pc.GraphNode#_dirtifyLocal or _dirtifyWorld respectively instead.” messages, that seem to be coming from the engine code itself for some reason. Other than that, we see a couple of delayed asset loads on start and that’s basically all we get to work with. Everything seems to be “constant”, no matter if there are glitches present or not.

There’s part of me that thinks I’ve heard this issue before but I can’t remember how it was fixed :thinking:

1 Like

I’ve managed to get a ‘glitch’ to happen on my laptop and it looks like it there’s a few spikes of GC.

The memory graph looks little suspect but I don’t know if that’s from FB or the game :thinking:
image

In my experience this is due to runtime resource usage - basically too much memory used up so audio gets choppy, and in worst cases just gives up working during a play session (fixes with page reload). It’s generally present/worse on low end mobile devices.

You could try reducing the ‘weight’ of audio at runtime by decreasing bitrate if a) that’s a possibility and b) you haven’t already tried it! If you can debug general RAM usage you may see that it’s high relative to what’s available on the device - that’d choke it too.

Well… We think we found the issue, but the solution seems rather bizarre: an audio source had null audio clips in several slots (those slots were left “empty” for us to be able to insert some optional sounds in case we decided to turn them on). So, when the script requested to play those, nothing unusual happened, apart from the fact, that RAM usage seemed to grow out of control (AKA memory leak of some sort). When we inserted some dummy sounds and set volume to 0, the problem disappeared, hopefully for good.

If the errors come back, we’ll inform you, but those null-clip memory leaks seem kind of unexpected…

1 Like

The memory leak is interesting :thinking: Good spot.