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 #2757

Closed ghost closed 1 year ago

ghost commented 1 year ago

Please note that this issue was already reported in https://github.com/googleads/googleads-mobile-unity/issues/2728. @NVentimiglia confirmed the issue and said a fix will be available in the next release. Since the next release is published and no function of the 'RewardedInterstitialAd' class is fixed I'll reopen the issue. Please do not close this issue until you you fixed it. Thanks

[REQUIRED] Step 1: Describe your environment

Unity version: 2021.3.16f1
Google Mobile Ads Unity plugin version: v8.3.0
Platform: Android
Platform OS version: Target: API 33
Any specific devices issue occurs on: Tested on different devices with different Android versions
Mediation ad networks used, and their versions:

[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.3.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

@TheGoodEvilBen

Thanks for the reminder. I have confirmed this is still an issue and will push for a fix.

NVentimiglia commented 1 year ago

This will be fixed next release.