FMOD music will not resume after Ironsource Ads

Hi all,

Unity Version: 2021.3.11f1
FMOD For Unity Version: 2.02.13
Ironsource Plugin for Unity Version: 7.3.0.1

When running my Unity game on iOS, the FMOD music plays normally when the game starts.
When I play an ad via the Ironsource Ad SDK (Currently the recommended and officially supported ad provider for Unity), the music stops when the ad runs (expected behavior). However, when the ad completes, I hear a single note of the FMOD music resume, then the music stops permanently. Nothing I seem to do brings the music back after this except:

  • Pressing the iOS home button then returning to the game (odd that this fixes it)
  • Restarting the app

Both of these actions restore the FMOD music until another ad is played.

This issue does not occur at all on Android, the music pauses when ads begin and resumes normally when the ad completes, as expected.

This is an issue I have been experiencing for some months. I have had a VERY long support ticket open with Ironsource, however after much investigation on their part, they say the issue seems to be with FMOD. They have told me they are handling the starting and stopping of game audio correctly under the hood on their end.

This seems to be confirmed if I add a normal, non-FMOD audio source to my scene, this standard Unity music/audio behaves as expected. Stopping and starting before and after the ad plays (when configured to do so) and playing throughout the ad if Ironsource is configured for that behavior instead.

Contrary, no matter what I seem to do with the Ironsource configuration, the FMOD audio always stops when the ad begins and never returns properly afterward. Only a single note playing post-ad and then stopping permanently.

I have tried calling RuntimeManager.CoreSystem.mixerResume (); when the add finishes, based on an old forum post. But this did nothing to help.

I also tried downloading a brand new version of FMOD Studio (2.02.14) and opened the FMOD project with that (as the original FMOD project was made with a much older version). The Project upgraded just fine to the new version and sounded fin in Studio. I then built the project, and Unity (as expected) detected updated banks and refreshed them. Upon building the game for iOS, the same issue is experienced.

I do not know what else to try.

If anyone has any suggestions, or if I can give any additional information, please let me know.

This issue is driving me totally crazy, so if anyone could assist I would very much appreciate it.

Does anyone know if there is anything like an official support email that I can contact for assistance with this?

Just bumping this thread. Surely someone else is using FMOD music and Ironsource ads in their Unity Game. Even knowing if this issue has been noticed by anyone else would be really helpful.

Can you also please try updating the FMOD for Unity integration to 2.02.14? We made some changes to iOS output in the latest release, and it was to solve a problem that sounds similar to yours and might be worth trying first.
I have not been able to reproduce this issue in the past, if you could please upload a minimal reproduction to your FMOD Profile I will try reproducing it on our end. Just a Unity project with everything removed except a scene that reproduces the issue should be sufficient.

Hi Jeff,

Thanks so much for replying! I will definitely try the updated package (I did think I was on the latest, must have been released recently?). If this helps in any way I will post back here.

If not, I will try to create a simple project that replicates the issues I am seeing. What is the best method to provide this to you? I am not great with FMOD (as I am not a sound designer), so if there is a way to provide you with a Google Drive link or something privately that would be best. That way if I need to leave a little bit of our original content in there I can.

Hopefully it’s as simple as updating- worth double checking in any case.
You can share projects with us privately by uploading to your FMOD Profile. You will need to register your project with us before the upload option becomes available, if you haven’t done so already.

Hi Jeff,

This will be a rather long post, but I would like to be thorough.

I took a look at the patch notes for FMOD Version 2.02.14 and noted that the related bug fix you were referring to seemed to regard music not starting again after opening and closing Siri.

I decided to first verify this was an issue before upgrading anything and sure enough if I opened and closed Siri in my game, the music would stop and not come back.

  • I downloaded the latest release of FMOD for Unity version 2.02.14 and installed it into my game.
  • I built out the game for iOS as normal, then built the resultant XCode project on my Mac OS machine.
  • When I ran the game, sure enough the issue with Siri was now fixed, the music returned after opening and closing Siri.
  • Excited, I tried playing an ad, however still once the Iron Source ad completed, my game music did not returned.

Given this disappointing result, I set about creating you a demo project to replicate the issue as requested.
In order to re-produce the issue I followed these steps:

  • Downloaded a project setup for me by the Iron Source support staff that uses the latest Iron Source Plugin for Unity
  • Deleted the Library folder (as this is good practice when copying a project from one system to another)
  • Opened the project and let the Library folder re-build
  • Re-added the IronSourceDemo scene to the build settings
  • Switched to iOS platform
  • Updated the package id, version and bundle in build settings
  • Opened FMOD Studio and saved a copy of the Example.fspro project into my game directory
  • Tested the music worked in FMOD Studio, and clicked Build to generate the banks
  • Downloaded and installed the latest version of FMOD for Unity (2.02.14) as recommended by users on the FMOD forum
  • Performed first time FMOD setup wizard and pointed it at the FMOD Example project I copied into the Unity Project
  • Opened the “IronSourceDemo” scene in Unity
  • Opened the IronSourceDemoScript.cs file and added two additional buttons to the GUI, one for playing and one for pausing FMOD music
  • Added an FMOD Event Emitter and Listener onto the main camera object and hooked everything up so that the two new buttons would play and pause the FMOD music
  • Built the game out for iOS which created the XCode project successfully
  • Copied the outputted project to my MacOS computer
  • Right clicked on the folder containing the XCode project and opened a new terminal window
  • Ran pod install to install the Iron Source SDK packages that are project dependencies for ads to work
  • Opened the newly created .xcworkspace file to open the project in XCode
  • Set my provisioning profile and certificate on the Signing and Capabilities tab
  • Turned off Bitcode under Build Settings for both the Unity-iPhone and UnityFramework targets
  • Built the project and installed it on my iPad (5th generation) running iPadOS Version 16.2
  • Clicked the button to “Play Unity Sound”, then clicked “Show Reward Ad”
  • Noted that the music stopped as soon as the ad began, then started again as soon as the ad had fully completed
  • Clicked the button to “Play FMOD Sound”, the clicked “Show Reward Ad”
  • Noted that the music stopped as soon as the ad began, but did not come back when the ad completed

I have now setup my profile on the FMOD website and registered the project, it is currently awaiting approval before I can upload the example project for analysis.

Do you have any idea how long this usually takes?

Regards,

Hi Jeff,

I have successfully uploaded a .zip of my project to my account. I have included the Unity Project, a freshly built XCode project straight out of Unity and a readme.txt with all the steps I followed to replicate the issue.

Can you please take a look and let me know if you are able to replicate the issue and what my next steps should be. I am happy to raise a support ticket somewhere if that is helpful.

Thanks!

Hi, apologies for the delayed response - Jeff is currently away.

This issue here, from what I can see, is a problem with Ironsource, specifically due to how FMOD and Ironsource handle audio interrupts on iOS differently. On iOS, FMOD specifically hooks into AVAudioSessionInterruptionNotification and UIApplicationDidBecomeActiveNotification, which are iOS system notifications, to suspend and resume the mixer. The Ironsource Unity integration, as far as I can tell, handles interruptions independently of this, instead opting to pause and resume Unity itself when, for example, a reward video is played. As such, the iOS notifications that FMOD uses to pause and resume are never fired, and Ironsource appears to simply grab audio session focus and not return it.

Unfortunately, I cannot offer an exact solution, but I would suggest that:

  • Due to how FMOD has its audio session taken by Ironsource, it may never actually be suspended in the first place, so your previous test of calling RuntimeManager.CoreSystem.mixerResume() may require you to call RuntimeManager.CoreSystem.mixerSuspend() immediately beforehand
  • You could edit the relevant part of the Ironsource integration to call RuntimeManager.HandleInterrupt(), which is the relevant FMOD callback on iOS, when Ironsource pauses Unity, or simply call it yourself at the appropriate time

Hi Louis,

Thanks so much for getting back to me. I will forward this onto my support contact at Ironsource. I will also attempt the two suggestions you made.

Followup questions.

  1. Is there somewhere that I can find documentation on the FMOD SDK, like a scripting reference or API reference? I would like to know more about what the methods you suggested in dot point 1 do.

  2. If I do try suspending and resuming the mixer, would you suggest doing this before I even call Ironsource to start an ad, or on the ironsource “ad started” callback?

  3. With the RuntimeManager.HandleInterrupt() method, should I be calling this before the ad starts, on the ad started callback, or after the ad finishes? I am not really sure what the HandleInterupt() does (Again SDK doco would be swell for this).

I will update here once I have tested and seen if this helps at all with my issue.

Thanks again!

I would recommend taking a look at the Unity Integration’s Scripting API Reference. In the case of RuntimeManager.HandleInterrupt(), it’s a private function, so it isn’t listed, but you can still examine the source itself in RuntimeManager.cs, line 702.

Essentially, if an interruption begins (began = true), it pauses all events with RuntimeManager.PauseAllEvents(began), and the suspends the mixer with RuntimeManager.coreSystem.mixerSuspend();.

If an interruption ends (began = false), it does the opposite, unpausing with RuntimeManager.PauseAllEvents(began) and resuming the mixer with RuntimeManager.coreSystem.mixerResume();.

It is basically identical to RuntimeManager.OnApplicationPause(), which is what is used for non iOS platforms to handle pausing FMOD on losing focus.

Modifying the Ironsource callback would likely be more convenient, as the FMOD needs to be told to resume as well - something which will probably be easier to Ironsource to handle instead of manually scheduling it or finding the appropriate time to resume it yourself.

My mistake - since RuntimeManager.HandleInterrupt() is a private function, you won’t be able to call it externally. However, making a duplicate function that is public, or your own copy of it elsewhere, would work.

That said, “before the ad starts” and “on the ad started callback” should have essentially the same outcome, so either will work. You should be calling your suspend/resume function once before the ad starts, passing in true to signify that an interruption has occurred, and once when the ad stops, passing in false to signify that an interruption is no longer occurring.

Hi Louis,

Thanks for the additional details. Much appreciated. I have forwarded you notes on to the Ironsource support team to see if they agree with your thoughts.

In the mean time I have implemented the following 2 methods on my audio manager as public methods.

public void PauseFmod () {
RuntimeManager.PauseAllEvents (true);
RuntimeManager.CoreSystem.mixerSuspend ();
}

public void ResumeFmod () {
RuntimeManager.PauseAllEvents (false);
RuntimeManager.CoreSystem.mixerResume ();
}

Then, right before showing a reward ad I added the below

#if UNITY_IOS && !UNITY_EDITOR
AudioMan.Instance.PauseFmod ();
#endif

Then on the ad closed callback I added

#if UNITY_IOS && !UNITY_EDITOR
AudioMan.Instance.ResumeFmod ();
#endif

This code is called successfully, but sadly does not seem to have any impact on my issue. The music stops just as the ad starts (as it did before), but does not resume on ad close.

I also added buttons on my main menu that call AudioMan.Instance.PauseFmod and AudioMan.Instance.ResumeFmod directly. These function fine before an ad plays, but do nothing once the ad has completed. Something is very wrong here and I am struggling to understand where the issue lies, with Ironsource or with FMOD. Both companies are telling me they are handling things correctly.

Is there anything else you can suggest?

Any assistance is very much appreciated.

So I’ve done a little more investigation into the issue - it seems that my statement that:

is incorrect. What actually happens is when Ironsource plays an ad (i.e. a rewarded video) the FMOD system continues to run in the background and attempt to output audio. In theory, both FMOD and Ironsource will both output audio simultaneously, no problem.

However, the issue is that Ironsource does something to the AudioSession that changes the length of its audio buffer. For example, by default FMOD’s buffer is ~16KB (512 byte buffer * 4 buffer blocks * 32 bit float) long, but on playing a rewarded video, the buffer the AudioSession requests changes length (e.g. to 23040 bytes). This immediately triggers an error, as the FMOD system’s buffer length is insufficient, and causes FMOD not to output audio. Ironsource doesn’t appear to reset the buffer length either, meaning that FMOD continues to receive the error and not output audio, even after the ad is finished.

If Ironsource did reset the AudioSession’s buffer length to what it was before the rewarded video, then suspending FMOD before starting an ad and the resuming in the relevant callback or in OnApplicationPause(false) should work.

As a workaround, increasing FMOD’s buffer length to be larger than what Ironsource uses will ensure that audio is outputted correctly. You can do this in Unity at FMOD → Edit Settings → Platform Specific → DSP buffer length - doubling it to 1024 (effectively 32KB) worked for me. However, I have noticed that the buffer length Ironsource uses can vary, so there may be situations where the buffer length it uses exceeds FMOD even at 1024.

1 Like

Hi Louis,

Thank you so much for looking further into this. I really appreciate it. This new information seems very promising.

Sadly I am away on holiday for A week. But i am dying to see if this resolves the issue. I will check this out as soon as i return.

In the meantime I have forwarded the information on to the Ironsource team. I will be interested to hear their thoughts on this.

Thanks and regards,

1 Like

Hi Louis,

I am so happy to say that after almost 6 months of this issue plaguing me, it is finally resolved, thanks to you going the extra mile and really taking my issues seriously. So I cannot thank you enough.

I have informed Ironsource of what you said above. They responded with the below.

"Our dev team is wondering why by default, the FMOD is calling resume? Because there are situations where our Ad is playing while moving to background. Than when back to foreground - the App continue to play, while the Ad is still presenting.

Maybe - can you direct us to the FMOD representative who wrote this message, so we can take it directly?"

How can I inform Ironsource of how to reach you, or some other member of the FMOD team in order to contact you directly regarding this issue and their associated questions?

Again, many thanks.

Not a problem! I’m happy to hear you managed to resolve the issue. If the solution you’re using is one that you can post publicly, posting it here for other people running into the same issue would be great.

Please direct them to email support@fmod.com, and get them to link this forum thread in the email.

Hi everyone, the resolution posted below fixed this problem for me.

1 Like