Unity iAD Crashing in iOS 9

I have an game that’s been on the App Store and running on all devices running iOS6 through 8.4.1 with no reported crashes.

During the iOS 9 Betas and including the Final iOS 9 release, my game is crashing when showing/closing iAds – both interstitial and banner:

  • Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason:‘accessing _cachedSystemAnimationFence requires the main thread’
  • ***Firstthrow call stack:
  • (0x24e8326b0x3657ae170x24e831410x25c0b1e10x291a14a50x291a15510x291ecdb70x2963efdb0x29642cbf0x28f278e30x28f9af990x28f8c01b0x28f0998d0x28f0a5110x28f0a4330x291ffeab0x28f095970x105c9b0x36594f670x51f9390x7611ef0xf285810xefc0490xef75350xefbf870xf112e30xf167310x36e5a8730x36e5a7e70x36e58740)
  • libc++abi.dylib: terminating with uncaught exception of type NSException

I’m over my head on this one.

I am building with Unity 5.2.0p1, IL2CCP and the latest version of Xcode on OS X Yosemite. Is there a fix?

Thanks, Manny

We’re having the same problem. Haven’t solved it yet.

I am facing the same problem… from the App Store crash logs, here is the stack trace:

It is only happening on iOS 9.0 and above. Built with Unity 4.6.x and Xcode 6.x.

Interesting. I’m in the absolute final days before publishing. My iAd banner test ads were refusing to show up on iOS 9. Since I already had admob as a backup, and since I heard iAD rates have absolutely tanked since they switched from 500,000 to 50 dollar minimum ad buys, I just removed it and didn’t look any further. Wonder if that inability to serve test ads was related to this issue.

Here’s an update, just built my project using Unity’s latest 5.2.1f1 – still crashing. :frowning:

This might be the related bug: Unity Issue Tracker - [iOS] AdBannerView & ADInterstitialAd not working with iOS9

It says ‘Fixed’ but does not appear to be included in the release yet.

Had to pull my game from iTunes today for the same crash. Seems like it crashes after it’s already been shown in a scene and then returning back to that same scene. Causes this crash on the [_view removeFromSuperview] call… Tried nulling out the banner when the scene unloads, hiding it, etc., but still crashes on returning to the scene with the banner. Downloading 4.6.8p2 to see if it helps :confused:

[Edit: issue exists in 4.6.8.p2]

Has anyone figured this out yet? From what I can tell AdBannerView is broken. By completely ripping it out the bug goes away but then I can’t make money :confused:

Alright I figured out a more legit fix here: iphone - removeFromSuperview doesn't work - Stack Overflow

Only what we need to do is replace [_view removeFromSuperview]; with [_view performSelectorOnMainThread:rage:selector(removeFromSuperview) withObject:nil waitUntilDone:NO];

This fixes my crashes and still runs the ads fine. Hope this helps you all out/I hope this gets fixed for real soon.

Edit: Angry face is : and @ together with no spaces. Although that is how I was feeling for a while…

Sermer, thanks for the fix. It work like a champ although interstitial ads are not showing at all. Any thoughts on this? Also, I read on another thread somewhere that simply removing the line [_view removeFromSuperview]; also fixes the issue and it appeared to but I was not sure if it was causing memory leaks or other negative effects. Do you have any thoughts on this.

And also, patch 5.2.1p2 is still broken on this issue.

1 Like

Sermer - thank you soooooo much, this fixed the crash for me!

For others, find the following line in Classes/UI/iAD.mm:

[_view removeFromSuperview];

… and replace it with:

[_view performSelectorOnMainThread:@selector(removeFromSuperview) withObject:nil waitUntilDone:NO];

Thanks again!

1 Like

all iad issues should be fixed 5.2.1 Patch 4 (both banner crashing and fullscreen ads not working)

Will it be addresses in the 4.6 release at some point as well? Thanks much.

I haven’t used interstitial ads yet so I don’t know and same for the memory leak. It seems like yanking out the remove function would cause a memory leak though. I’m new to Unity so everything is still new to me. I came up with that fix by trial and error :slight_smile:

Glad my fix worked for you guys though!

I was running 5.2.1f1 with the most current xcode and the crash was still happening. Haven’t checked again since I made my post since my fix worked. Are patches applied automatically or do I need to redownload 5.2.1?

edit: K figured out I need to download them manually but 5.2.1p3 is the most recent patch. Any word on when patch 4 will come out?

Hey, Im still experiencing issues with iAd interstitials. Running Unity 5.2.1p4. Since iOS 9 the ads simply dont display. No ad failures or anything like that. Very perplexing :frowning:

If you’re using sandbox did you set Fill Rate to 100% in developer settings? If you did, could you try downloading latest build 5.2.3f1 and if it still doesn’t work submit a bug report with your project?

Yup fill rate is set to 100%. The banner displays just fine, and the application receives an ad, it just doesnt get displayed. Ill try upgrading now.

Just upgraded and have the same issue. It seems like its not receiving an ad after requesting one.

Im using Prime31s iAd plugin. Ive also tried with the AdMob plugin with iAd mediation and still no luck.

Did you try using Unity - Scripting API: ADInterstitialAd ? Because there is probably not much we can do if only third party plugins are not working (you should try contacting their authors).