AdMob SDK 7.6.0 is Grabbing the NSUncaughtExceptionHandler

640 views
Skip to first unread message

Mark Riley

unread,
Feb 1, 2016, 5:26:44 AM2/1/16
to Google Mobile Ads SDK Developers
AdMob SDK: 7.6.0
Device: iPhone 6 running iOS 9.2

The AdMob SDK appears to be taking over the NSUncaughtExceptionHandler. I have no interest in AdMob handling my crashes and this potentially interferes with my own crash reporting tool, Crashlytics. 

I call [GADMobileAds disableSDKCrashReporting] in didFinishLaunchingWithOptions right before I initialise Crashlytics, but I still get a warning from Crashlytics later on saying that the NSUncaughtExceptionHandler is in use.

Is this to be expected, or is it possible for AdMob to release its hold on the NSUncaughtExceptionHandler?

Mark Riley

unread,
Feb 1, 2016, 5:31:39 AM2/1/16
to Google Mobile Ads SDK Developers
Should have mentioned that Crashlytics is reporting that the method GADHandleUncaughtException is assigned to the NSUncaughtExceptionHandler

Veer Arjun Busani

unread,
Feb 1, 2016, 3:06:20 PM2/1/16
to Google Mobile Ads SDK Developers
Hi Mark,

Thank you for reaching out to us about this crash. Would you be able to share the crash log from Crashlytics? 

Thanks,
Veer Arjun Busani
Mobile Ads SDK Team

Mark Riley

unread,
Feb 1, 2016, 5:19:34 PM2/1/16
to Google Mobile Ads SDK Developers
Hi,

I am not experiencing a crash, so there is no crash log. The warning from Crashlytics is being written to the console.

I was pointing out that AdMob was grabbing the NSUncaughtExceptionHandler even though I disabled crash reporting. This interferes with Crashlytics and could potentially lead to crash data not getting through to Crashlytics.

I was 'potentially' since I don't know what the AdMob SDK is doing behind the scenes, so any light you could shed on this would be useful...


Veer Arjun Busani

unread,
Feb 2, 2016, 9:55:38 AM2/2/16
to Google Mobile Ads SDK Developers
Hi Mark,

I have tested integrating Crashlytics in our sample app, both in Objective-C and SWIFT and was unable to reproduce any issue. I would suggest you to try updating to the latest version for both the Fabric and our AdMob SDK. You can also use our sample app as a base and test it by disabling crash reporting by our SDK.

Mark Riley

unread,
Feb 2, 2016, 11:18:18 AM2/2/16
to Google Mobile Ads SDK Developers
Ok, I have now downloaded the sample app (I used the InterstitialExample) and I am using the latest AdMob SDK and the latest Crashlytics SDK and have reproduced the warning. I have also discovered that the warning does not appear if you run the app direct from Xcode. Below is a reliable reproduction scenario:

1) Integrate Crashlytics and make sure that didFinishLaunchingWithOptions looks like this

  [GADMobileAds disableSDKCrashReporting];
    [Fabric with:@[[Crashlytics class]]];

2) Run the app in the Simulator via Xcode and then stop it again

3) From the Simulator, do 'Menu -> Debug -> Open System Log...'. This is where you will see the warning appear

4) Optional: In the Console that appears, paste 'NSUncaughtExceptionHandler' into the Search box filter. 

5) Run the app in the simulator (by tapping on the icon, not via Xcode this time)

6) After a few seconds, you should see the warning appear in the system log console

If this does not work, it is possible that you may need to generate a crash first (I did this myself, so can't say for sure whether this made the warning appear). In that case you can paster the code 

[[Crashlytics sharedInstance] crash];


into the playAgain method in ViewController.m to force a crash (again, make sure the app was started direct from the simulator, not from Xcode). Then start the app again after it has crashed and the warning should appear.

This is reproducible 100% of the time. The same happens on an actual device.

Andrew Brogdon (Mobile Ads SDK Team)

unread,
Feb 2, 2016, 1:09:39 PM2/2/16
to Google Mobile Ads SDK Developers
Thanks for posting such detailed reproduction steps. It makes it much easier for us to dig into a situation.

You're correct that the Google Mobile Ads SDK registers itself with NSUncaughtExceptionHandler. I've spoken with the engineering team and gotten some more info for you:

- While we do implement a handler for uncaught exceptions, we do not short circuit the handling, which means any previously registered handlers should still get called (Crashlytics, though it generates a warning, appears to follow the same strategy). 

- Publishers often post crash reports from Crashlytics on this forum, so I can say with confidence that there are many apps using both SDKs successfully.

- If you'd like to disable the Google Mobile Ads SDK's automated crash reporting, you can do so via this method. I believe a handler is still registered (though it's a no-op at that point), so you may still see the warning.

Thanks!

-Andrew

Mark Riley

unread,
Feb 2, 2016, 1:25:26 PM2/2/16
to Google Mobile Ads SDK Developers
Thanks, that is good info. Based on that I have one last question then. Will it make any difference if I call disableSDKCrashReporting before I initialise Crashlytics, or after I initialise Crashlytics. In other words, is it best to do:

    [GADMobileAds disableSDKCrashReporting];
    [Fabric with:@[[Crashlytics class]]];

or

    [Fabric with:@[[Crashlytics class]]];
    [GADMobileAds disableSDKCrashReporting];

or is it unlikely to make any difference?


Andrew Brogdon (Mobile Ads SDK Team)

unread,
Feb 2, 2016, 2:24:57 PM2/2/16
to Google Mobile Ads SDK Developers
If I had to guess, I'd say the behavior is likely identical in both cases. The Crashlytics docs do request that they be initialized after all other handlers, though, so I'd probably go with the former rather than the latter.

-Andrew
Message has been deleted

Saleh Albuga

unread,
Jun 15, 2016, 8:16:10 AM6/15/16
to Google Mobile Ads SDK Developers
Hi, Even with calling [GADMobileAds disableSDKCrashReporting] first & initializing Crashlytics after all other frameworks I'm still having the same problem [Crashlytics:Crash] Warning: NSUncaughtExceptionHandler is 'GADCategories_GADSlot_AdEvents' 
Note that I'm using the latest versions of both frameworks
Reply all
Reply to author
Forward
0 new messages