Crash in showAdFromRootViewController


#1

Hello, I’ve recently integrated the MoPub SDK and pushed an update to my iOS application. The issue is that we are now receiving many new reports of a crash due to the Facebook Audience Adapter provided by MoPub.

I do not make a call more than once, I am only calling this interstitial at the start of my app. Thanks.

Here is the call stack:

Exception Type: SIGABRT
Exception Codes: #0 at 0x3b7161f0
Crashed Thread: 0

Application Specific Information:
*** Terminating app due to uncaught exception ‘InvalidOperationException’, reason: ‘showAdFromRootViewController may only be called once’

Application Specific Backtrace 1:
0 CoreFoundation 0x309ccf03 + 130
1 libobjc.A.dylib 0x3b161ce7 _objc_exception_throw + 38
2 Secret Free 0x000ccf1f +[FBAdUtility throwExceptionWithName:reason:userInfo:] + 150
3 MY APP 0x000cce7d +[FBAdUtility throwExceptionWithName:reason:] + 44
4 MY APP 0x000b5023 -[FBInterstitialAd showAdFromRootViewController:] + 126
5 MY APP 0x00088cdf -[FacebookInterstitialCustomEvent showInterstitialFromRootViewController:] + 210
6 MY APP 0x000549bf -[MPInterstitialCustomEventAdapter showInterstitialFromViewController:] + 62
7 MY APP 0x0006cbbd -[MPInterstitialAdManager presentInterstitialFromViewController:] + 84
8 MY APP 0x00074b6d -[MPInterstitialAdController showFromViewController:] + 172
9 MY APP 0x0005a02d -[MainSideViewController interstitialDidLoadAd:] + 52
10 MY APP 0x00074d0f -[MPInterstitialAdController managerDidLoadInterstitial:] + 110
11 MY APP 0x0006cb47 -[MPInterstitialAdManager loadInterstitialWithAdUnitID:keywords:location:testing:] + 174
12 MY APP 0x00074a9f -[MPInterstitialAdController loadAd] + 162
13 MY APP 0x00059fe3 -[MainSideViewController showAd] + 410
14 CoreFoundation 0x3098ef39 + 12
15 CoreFoundation 0x30902de9 __CFXNotificationPost + 1720
16 Foundation 0x312edcc5 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
17 UIKit 0x3327ae19 + 440
18 CoreFoundation 0x30905305 + 124
19 CoreFoundation 0x3098ef39 + 12
20 CoreFoundation 0x3098f28b + 138
21 CoreFoundation 0x30998015 + 12
22 CoreFoundation 0x3099738f + 242
23 CoreFoundation 0x30995ff9 + 1488
24 CoreFoundation 0x309007a9 _CFRunLoopRunSpecific + 524
25 CoreFoundation 0x3090058b _CFRunLoopRunInMode + 106
26 GraphicsServices 0x3586d6d3 _GSEventRunModal + 138
27 UIKit 0x3325f891 _UIApplicationMain + 1136
28 MY APP 0x0006f653 -[UIProgressView observeValueForKeyPath:ofObject:change:context:] + 5874
29 libdyld.dylib 0x3b65fab7 + 2


#2

Hey SepiaApps,

Facebook seems to be crashing when the adapter calls ‘showAdFromRootViewController’ multiple times as stated.

Facebook has a limit for how many times an ad can be shown/called within a 15s period. See here for documentation.

Are you requesting ads/showing multiple ads within a short period with the same device in testing? Does this issue happen if you give appropriate time between ads? (e.g. 30s)

Let us know, so that we may troubleshoot further.

Thanks!


#3

I think I figured out the issue.

  1. When a user launches the app a full screen facebook ad is shown.
  2. They hit the home button and close the app without dismissing the shown ad.
  3. They again launch the app, and the crash occurs because the first ad was not dismissed before closing the app.

I’ve gotten around the crash by using a bool to determine if an ad was presented but not dismissed. I don’t attempt to call “LoadAD” if an ad is present.

This crash only occurs in facebook ads, admob, etc, all are fine… they error out the ad load but do not crash. So it can be baked into the source either on the SDK level or the Adapter.

Thanks.


#4

Hello SepiaApps,

Thank you for letting us know of the solution you have found. I’ll work with our team to try to reproduce the issue you have seen and see if there is anything we can do on our end with the adapter to prevent this issue from happening.

Thanks!


#5

Is anything been done to fix this problem? It is still occurring in MoPub 4.5.1

To replicate:

  1. Show interstitial
  2. Close App
  3. Close Interstitial
  4. Try showing another interstitial

#6

Hi @wsidell,

MoPub has updated to latest SDK version-4.9, can you please let us know if the issue is seen in the latest as well?

Thanks!