i implemented UnityAds into our iOS project today but once in a while they seem to not work and block input to the game until you either minimize the app and bring it up again, or sometimes just wait for several minutes.
Basically i have a “Watch ad” button and once the user clicks it, it triggers something like this:
I can see the button getting disabled and XCode log shows that it’s trying to display the ad.
2017-01-26 15:09:43.413385 appName[354:37740] I/UnityAds: +[UnityAds show:placementId:] (line:111) :: Unity Ads opening new ad unit for placement video
2017-01-26 15:09:43.773209 appName[354:37999] I/UnityAds: +[UADSApiSdk WebViewExposed_logInfo:callback:] (line:57) :: Opening performance ad with orientation 24
But nothing happens and i can no longer interact with anything else in my game, it’s like it opened a new invisible window on top of my game, but without showing the ads. Like i mentioned, sometimes just waiting for several minutes makes the ad eventually show up, but also minimizing/maximizing the game works.
This is what xcode prints out when an add shows up successfully:
2017-01-26 15:09:43.413385 appName[354:37740] I/UnityAds: +[UnityAds show:placementId:] (line:111) :: Unity Ads opening new ad unit for placement video
2017-01-26 15:09:43.773209 appName[354:37999] I/UnityAds: +[UADSApiSdk WebViewExposed_logInfo:callback:] (line:57) :: Opening performance ad with orientation 24
2017-01-26 15:09:45.326384 appName[354:37999] I/UnityAds: +[UADSApiSdk WebViewExposed_logInfo:callback:] (line:57) :: Unity Ads event: sending start event to https://adserver.unityads.unity3d.com/mobile/gamers/50507b163822f20000000001/video/video_start/000000000000000000000000/1273152
As you can see it has a third line at the bottom that seems to return the proper ad video URL, that line is missing whenever it fails.
I tried this with Unity 5.5.0f3 and 5.5.1, tried both using ads through the Services window and also through the package from the Asset Store. Nothing seems to make a difference really.
Has anyone else run into this issue before? Any idea what this could be?
There are known issues with these editor versions, but it should be fixed if you disable the services integration for Ads and use the Asset Store package:
After doing the Asset Store integration, have you tried rebuilding and uninstalling / reinstalling?
If your issue persists - can you send an e-mail to unityads-support@unity3d.com along with your project so that we can investigate it further.
yeah i did try to disable the services integration and use the asset store package, but that didn’t seem to have helped.
Basically i started in 5.5.0, used the service integration, ran into the problem, read here that that might cause issues in certain versions, disabled the services, downloaded and used the package, didnt work, then upgraded to 5.5.1 and tried with the package only, no success.
When i built the project in 5.5.1, i did a “replace”, but i’ll try deleting the xcode folder all together and make a clean one.
Besides having to use the package, do you think there is anything else that could possibly help? Any temporary work arounds?
Might not be able to send this project over but i’ll double check, or i might try it in an empty one with just the ads stuff, to see if that causes issues too.
Not sure if helpful at all, but i enabled the debug mode for Advertisement, this is the last entry when it breaks, nothing happens afterwards (unless i minimize, etc):
How did you integrate the Asset Store package? Did you remember to run Advertisement.Initialize(gameId,testMode); ?
After that, did you wait until Advertisement.IsReady() returns true before trying to run Show()?
Other than that - I’d like to see a screenshot of your services window and perhaps UnityConnectSettings.asset under ProjectSettings (fist, change the asset serialization to text only from Editor preferences) Unity - Manual: Editor
yeah i do call Initialize in the start of my GameManager script (which has DontDestroyOnLoad enabled). This does not need to be called before every ad call, correct?
Exact code is here:
// in my gamemanager
private void Start() {
string gameId = null;
// not using android yet
#if UNITY_ANDROID
gameId = "";
#elif UNITY_IOS
gameId = "1273152";
#endif
if (Advertisement.isSupported && !Advertisement.isInitialized) {
//Advertisement.debugMode = true;
Advertisement.Initialize(gameId, false);
}
}
// In my ads script, gets called much later than the initialize
public void WatchAd() {
if (!watchedAd) {
WatchAdButton.interactable = false;
StartCoroutine(ShowAd());
} else {
WatchAdButton.interactable = false;
isOpen = true;
}
}
private IEnumerator ShowAd() {
while (!Advertisement.IsReady()) {
yield return new WaitForEndOfFrame();
}
// tried both with and without
//yield return null;
// isReady/inInitialized print out true in the logs, even in cases where ads dont show up
Debug.Log("Advertisement is ready: " + Advertisement.IsReady());
Debug.Log("Advertisement is initialized: " + Advertisement.isInitialized);
Debug.Log("Advertisement is showing: " + Advertisement.isShowing);
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show(options);
yield return null;
}
Also here is my services window and my UnityConnectSettings.asset:
Thanks for providing this. Nothing unusual there though.
Yes - you only need to initialize ads in the beginning. After that - you need to wait until Advertisement.IsReady() returns true. Then you can run Advertisement.Show();
Maybe you’re showing too many ads? There’s a limit of 25 ads per user per day. To avoid this - use test mode or add your device advertising ID to the list of test devices from the https://dashboard.unityads.unity3d.com
i am using test mode through the Advertisement.Initialize(“id”, true);
Is there a difference between this one and the one on the dashboard?
And yes like i mentioned before a few times, i do wait for IsReady before i even call the Show.
I know i’m terrible at explaining things sometimes, but to summarize what is happening:
I click a button
The button checks if Advertisement.IsReady returns true
Only if it returns true, i call Advertisement.Show()
9 out of 10 times (not the actual numbers, it’s random) it brings up the ad ViewController properly and displays the app
The other 1 out of 10 times it brings up the ViewController which is completely empty and transparent. No ad is loading unless i minimize to the desktop and bring up the app again. This empty view controller (not sure if that’s 100% what it is, but let’s call it that for now to make it easier) is blocking input to my app
I tried some “bruteforcing” as well by forcing a 2nd Show() if the empty viewcontroller shows up without actually showing an ad but the xcode log says that it failed cause an ad is already being displayed (which is not true).
Since there is no Advertisement.Cancel() or something, i can no longer interact with my app unless i do the minimize thing or restart.
We’re having the same issue where it runs perfectly fine 9/10 times but just hangs every now and then on iOS.
CPU on iPhone6 tends to be used in the region of 50%. @CaptainKiyaku do you remember what CPU usage percentages you had in your case?
We’ve seen this happen across the board though. (iPhone 7,8 and X)
This doesn’t happen when we test in ‘Test mode’. Is that a valid real-world test though?