googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.37k stars 1.08k forks source link

Sounds are gone just after rewarded ad! #1516

Closed vladici closed 1 year ago

vladici commented 3 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Just after rewarded video all sounds are gone (muted) forever! For now in code we do nothing about sounds. Game background music plays in parallel with rewarded video sounds.

rozatlabs commented 3 years ago

I’m having the exact same issue, users are telling me sound disappears after an ad and they have to restart the game. Also iOS 14.2, but one user was iPhone 11

p0w1nd commented 3 years ago

This is just a guess, but maybe it's worth trying:

AFAIK AdMob by default does not "pause" Unity when opening Ad, that's why if you don't explicitly pause game audio before showing ad then you will hear both game sound and ad sound at the same time - and for some reason, this may mess up the game audio when back from ad.

AdMob has this method to request it to explicitly pause/resume Unity every time we're opening/going back from ad: MobileAds.SetiOSAppPauseOnBackground(true);

In the Start method of my AdManager class, I do something like this for iOS:

void Start()
{
    MobileAds.Initialize(initStatus => { });

    #if UNITY_IOS
        MobileAds.SetiOSAppPauseOnBackground(true);
    #endif

    RequestRewardedAd();
    RequestInterstitialAd();
}
KingKlauz commented 3 years ago

I am facing the same exact issue. I am testing on iPhone 12 running iOS 14.4. After closing a rewarded ad, all audios are muted. I already have the MobileAds.SetiOSAppPauseOnBackground(true) code in my script. Using AdMob v5.4.0. Interstitial ads do not affect this sound muting, only rewarded ads.

Error from Xcode:

AVAudioSession_iOS.mm:1149 Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.

ttienqb commented 3 years ago

i have same error

Object2XD commented 3 years ago

Please Disable "Mute orher audio sources"

Str4tos commented 3 years ago

Hello. Disabling "Mute other audio sources" in Unity Player settings helps with the problem. Why do Unity Player settings mute all Unity Audio Sources after ad close?

jungletree commented 3 years ago

For Admob v5.4, it seems this bug will not happen for Unity5.6, Unity2017.4.40. But will happen for unity 2018.4.22. And some apps will make it happen. Have no idea what to do.

Object2XD commented 3 years ago

I don't know the exact reason.

The same setting is reflected in the SDK, and when the View containing the SDK's AudioMedia is opened, Unity's AudioSource may be disabled. (I think this is the reason why this issue does not occur with interstitial ads that do not include Audio Media.)

This setting does not need to be enabled in many games. It is common for players to change the background music of a game.

To understand the problem in more detail, you need to know the Unity implementation.

jungletree commented 3 years ago

Try the following two things seems fix this bug: 1) add code MobileAds.SetiOSAppPauseOnBackground(true);

void Start()
{
    MobileAds.Initialize(initStatus => { });

    #if UNITY_IOS
        MobileAds.SetiOSAppPauseOnBackground(true);
    #endif
    // ......
}

2) Disabling "Mute other audio sources" in Unity Player settings

beginner-lang commented 3 years ago

I have been added in the code "MobileAds. SetiOSAppPauseOnBackground (true);",And disabled" Mute other audio sources ", but there is still a chance that my voice will disappear after the advertisement is broadcast. Note that this is not necessarily the case, but the probability is high. Even if the same advertisement is sometimes normal, sometimes the sound of the game will disappear. Who can tell me what I should do? Thank you!

cathei commented 3 years ago

I had same issue, and it still remained after setting "SetiOSAppPauseOnBackground" and disabling "Mute other audio sources".

With some lead, I suspected that NiceVibration plugin that my project was using is holding some kind of audio api reference, related to Haptic api they use. Fortunately I didn't have to give up the plugin or haptic feedback.

NiceVibration has HapticController.ProcessApplicationFocus api to release and regain haptic binding. With code like below, I was able to show ad without this issue.

// release haptic binding
HapticController.ProcessApplicationFocus(false);

// wait until ad is closed
await ShowRewardedAd();

// regain haptic binding
HapticController.ProcessApplicationFocus(true);

Hope this helps anyone having same issue.

cihadturhan commented 2 years ago

Hope this helps anyone having same issue.

It definitely helped! It was such a difficult issue to find. Thank you for your time and dedication :)