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

RewardedInterstitialAd events are not called on the main Unity thread #2728

Closed ghost closed 1 year ago

ghost commented 1 year ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

Rewarded interstitial ad events do not occur on the main Unity thread, despite setting "MobileAds.RaiseAdEventsOnUnityMainThread" to true. Depending on what actions are taken in this event call-back, this may result in the application crashing.

This problem was already mentioned in the issue https://github.com/googleads/googleads-mobile-unity/issues/2676

Relevant Code:

As you can see here: https://github.com/googleads/googleads-mobile-unity/blob/v8.2.0/source/plugin/Assets/GoogleMobileAds/Api/RewardedInterstitialAd.cs

The events are still called via

_client.OnAdClicked += () => { if (OnAdClicked != null) { OnAdClicked(); } };

but should be called via

_client.OnAdClicked += () => { MobileAds.RaiseAction(() => { if (OnAdClicked != null) { OnAdClicked (); } }); };

NVentimiglia commented 1 year ago

Hi @TheGoodEvilBen

We have confirmed the issue and a fix will be available with the next release. Thank you for raising awareness.

Let me know if you need any additional support.