Some sounds in certain Unity scenes do not work on Android


#1

If I use a normal event emitter with start on create in two different scenes, it will work in both scenes on a Mac build, Windows build, in the editor, but on Android it only works in one of the two scenes and I cannot figure out why.
Some other sounds work…

There is no difference in the two objects from the two different scenes, also using the exact same audio track in FMOD.

The sound starts playing for 1 second and then simply stops.
I can see one error in my logcat logs which is:
Error setting CPU thread affinity

Once the audio randomly started working after a few minutes.

I’m testing on a One Plus 2.
Any ideas ?


#2

So some sounds started working again, and the logs say that this was triggered exactly when the battery dropped from 37% to 36%.

Seems like as if the system is shutting down some audio/music threads randomly and then bringing them back ?


#3

So some sounds started working again, and the logs say that this was triggered exactly when the battery dropped from 37% to 36%.

Seems like as if the system is shutting down some audio/music threads randomly and then bringing them back ?


#4

Hi Patric,

This is some very odd behaviour you’re experiencing.

As far as I know, there is no thread affinity for Android as it’s available for all cores. Can you post all FMOD errors logged from your logcat log? There might be something we’re missing.

Are you able to replicate this issue on any other Android device?

Thanks,
Richard


#5

Hi Richard, thanks for the reply! I’ve not created a mobile bank and we are using ogg vorbis, that’s not ideal for mobile. So I’m trying to use a more common file format, and create a separate mobile bank and see if that solves the issue. I can’t see any FMOD error that’s the thing, the audio simply doesn’t play.

Could I email you a full log?


#6

Hi Patric,

You can send the log through to support@fmod.com and someone will take a look.

Let me know if using a different file format in the Mobile banks helps.

Thanks,
Richard


#7

Unity audio does automatically compress it to the best fitting format specific to the platform. In FMOD does Unity still compress the sounds we add, or those it player exactly whatever we use in the bank ? Thanks

I will follow up with an email asap.


#8

Hi Patric,

As far as I’m aware, Unity shouldn’t compress your audio files further than what you’ve specified in your banks.


#9

Hi Richard, what is the preferable way of resetting a sound from an emitter. Just start playing it from second 0 again. Calling Stop() and then Start() works on PC but not on mobile. Looking into the C# implementation of Stop() it looks like you are freeing the instance, could this be a cause of this weird issue ? is this a race condition ?


#10

Hi Patric,

Calling Stop() shouldn’t free the instance unless Release() is also called on the instance at any point.

You can just call Start() on the event instance for it to start again from the beginning.


#11

Hi Richard. This is the implementation of Stop() in Unity:

public void Stop()
{
    if (instance.isValid())
    {
        instance.stop(AllowFadeout ? FMOD.Studio.STOP_MODE.ALLOWFADEOUT : FMOD.Studio.STOP_MODE.IMMEDIATE);
        instance.release();
        instance.clearHandle();
    }
}

#12

Hi Patric,

I can see the Stop() function contains a release and clearHandle call, so this is why it won’t work. After calling this function the event instance is no longer there to play. You can simply call start() on the event instance for it to begin again from the beginning.


#13

Good to know, thanks.
I wonder why it still works on standalone builds and the editor.


#14

Calling just Play() is working on Standalone and Editor, but is also not working on mobile sometimes… No errors in the logs


#15

This is called on a studio sound emitter, that is created in a previous seen and carried on through DontDestroyOnLoad maybe that has something to do with it… it is really weird though. Because not calling start() just unmuting works… Start works everywhere. And on mobile just sometimes, and sometimes it would just start after a few minutes out of nowhere


#16

I’ve just experienced the issue in another scene as well. Unrelated to DontDestroyOnLoad -> some sound only randomly work, or they start out of nowhere, or just simply don’t play at all.

Are multiple regions in FMOD not fully supported on mobile ?


#17

Unfortunately this is a production blocker for us, and makes it unusable


#18

Hi Patric,

Given the complexity and urgency of your issue it would be better for you to upload your Unity project for support to take a look.

Open your FMOD profile page (where you download FMOD Studio) and select the “Upload” tab and upload a .zip of your Unity project there.

Thanks,
Richard


#19

Hi Richard,

I think the issue might be too many concurrent parallel streaming sounds. Putting all sounds to not “streaming” seems to be working on android. I read somewhere that there is a pretty low limitation of parallel streaming sound effects.