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

iOS Bug: Ad callbacks not triggering (reproducible) #1879

Closed PokerDawg closed 2 years ago

PokerDawg commented 2 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

AdMob Event Issue (2021.2.1).zip

  1. build and run the provided project on iOS
  2. open the app and wait for AdMob to initialize and load an ad
  3. press the 'Show Ad' button
  4. press the X button on the interstitial test ad to close it
  5. immediately open the iOS control center (swipe down from the right side of the top edge of the screen)

Expected result: the ad closes and the OnAdClosed callback is triggered Actual result: the ad closes but the OnAdClosed callback is NOT triggered

Here are two videos:

Notes and findings:

irakli commented 2 years ago

Events aren't invoked from the main thread, so it's not guaranteed that you'll receive any callbacks.

Wrap your callbacks methods with this and it should work.

MobileAdsEventExecutor.ExecuteInUpdate(() =>
{
    // Your code
});
PokerDawg commented 2 years ago

Hello @irakli

Changing the AdMobManager.OnInterstitialAdClosed method from:

void OnInterstitialAdClosed(object sender, System.EventArgs args)
{
    LogMessage("Interstitial ad closed");
    RequestAndLoadInterstitialAd();
}

... to:

void OnInterstitialAdClosed(object sender, System.EventArgs args)
{
    MobileAdsEventExecutor.ExecuteInUpdate(() =>
    {
        LogMessage("Interstitial ad closed");
        RequestAndLoadInterstitialAd();
    });
}

... does not solve the issue. I can still reproduce the bug every single time I open the control center immediately after closing the ad.

NVentimiglia commented 2 years ago

@PokerDawg I implemented the suggested fix of wrapping the callback handler within ExecuteInUpdate(). The result looked correct to me (image below). I will be closing this issue, please feel free to reopen if there is something I missed or you are still stuck.

image image

PokerDawg commented 2 years ago

Hello @NVentimiglia

I have wrapped the AdMobManager.LogMessage method's contents in ExecuteInUpdate(), like your screenshot, and I am still getting the same result. Have you managed to reproduce the problem without ExecuteInUpdate()?

As an aside, if AdMobManager.OnInterstitialAdClosed looks like this

void OnInterstitialAdClosed(object sender, System.EventArgs args)
{
    MobileAdsEventExecutor.ExecuteInUpdate(() =>
    {
        LogMessage("Interstitial ad closed");
        RequestAndLoadInterstitialAd();
    });
}

... then does modifying the AdMobManager.LogMessage method with ExecuteInUpdate() even do anything? Presumably it's already getting called from an Update() somewhere, right??

Edit: how do I reopen this issue?

PokerDawg commented 2 years ago

@NVentimiglia This problem is still not solved. Can you reopen this? Or, I can create a new issue.

emcmeem commented 2 years ago

This problem is still not solved for me too

dethroneofall commented 1 year ago

@PokerDawg I implemented the suggested fix of wrapping the callback handler within ExecuteInUpdate(). The result looked correct to me (image below). I will be closing this issue, please feel free to reopen if there is something I missed or you are still stuck.

image image

This problem is still not solved.