Question

I'm experiencing strange crashes on my iOS application with Google Ad-Mob. Crash log is as follows:

SIGSEGV
VLPush-[GADDelegateManager didReceiveAd]

#   Binary Image Name   Address Symbol
0   VLPush  0x001e0ba0  testflight_backtrace
1   VLPush  0x001e03dc  TFSignalHandler
2   libsystem_platform.dylib    0x3aaa3062  _sigtramp
3   VLPush  0x000f202f  -[GADDelegateManager didReceiveAd] --------->>>>> CRASH 
4   VLPush  0x000e941b  -[GADBannerWebViewDelegate webViewDidFinishLoad:]
5   CoreFoundation  0x300ad503  __invoking___
6   CoreFoundation  0x2fff7eba  -[NSInvocation invoke]
7   CoreFoundation  0x2fffb652  -[NSInvocation invokeWithTarget:]
8   WebKit  0x388eff7e  -[_WebSafeForwarder forwardInvocation:]
9   CoreFoundation  0x300ac070  ___forwarding___
10  CoreFoundation  0x2fffb597  _CF_forwarding_prep_0
11  CoreFoundation  0x300ad503  __invoking___
12  CoreFoundation  0x2fff7eba  -[NSInvocation invoke]
13  WebCore 0x37f41b8c  _ZL20HandleDelegateSourcePv
14  CoreFoundation  0x3007518a  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
15  CoreFoundation  0x3007465a  __CFRunLoopDoSources0
16  CoreFoundation  0x30072e4e  __CFRunLoopRun
17  CoreFoundation  0x2ffddce6  CFRunLoopRunSpecific
18  CoreFoundation  0x2ffddaca  CFRunLoopRunInMode
19  GraphicsServices    0x34cfe282  GSEventRunModal
20  UIKit   0x3287fa40  UIApplicationMain
21  VLPush  0x000a0fd6  main in main.m on Line 16
22  libdyld.dylib   0x3a988ab6  start

Or:

SIGSEGV
VLPush-[GADDelegateManager didFailToReceiveAdWithError:]


#   Binary Image Name   Address Symbol
0   VLPush  0x10024506b testflight_backtrace
1   VLPush  0x10024466f TFSignalHandler
2   libsystem_platform.dylib    0x1980f7b1b _sigtramp
3   VLPush  0x1001523fb -[GADDelegateManager didFailToReceiveAdWithError:] --------->>>>> CRASH 
4   CoreFoundation  0x18b02209b -[NSArray makeObjectsPerformSelector:]
5   Foundation  0x18bb8e897 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke
6   Foundation  0x18bb8e783 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]
7   Foundation  0x18bb8f7db -[NSURLConnectionInternal _withConnectionAndDelegate:]
8   Foundation  0x18bc33fdf _NSURLConnectionDidFail
9   CFNetwork   0x18acb93c3 ___ZN27URLConnectionClient_Classic17_delegate_didFailEP9__CFErrorU13block_pointerFvvE_block_invoke
10  CFNetwork   0x18acb76e3 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2
11  CoreFoundation  0x18afd508f CFArrayApplyFunction
12  CFNetwork   0x18ac2cbeb _ZN19RunloopBlockContext7performEv
13  CFNetwork   0x18ac2ca67 _ZN17MultiplexerSource7performEv
14  CFNetwork   0x18ac2c8a3 _ZN17MultiplexerSource8_performEPv
15  CoreFoundation  0x18b097043 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
16  CoreFoundation  0x18b09639f __CFRunLoopDoSources0
17  CoreFoundation  0x18b094637 __CFRunLoopRun
18  CoreFoundation  0x18afd56cf CFRunLoopRunSpecific
19  GraphicsServices    0x190c61c0b GSEventRunModal
20  UIKit   0x18e106fdb UIApplicationMain
21  VLPush  0x1000fbbf3 main in main.m on Line 16
22  libdyld.dylib   0x197f7fa9f start
23      0xffffffffffffffff  0xffffffffffffffff

The way I'm using Ad-Mob is this:

CGRect statusBarRect = [UIApplication sharedApplication].statusBarFrame;
CGRect navigationBarRect = self.navigationController.navigationBar.frame;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

    // Google AdMob
    // Initialize the banner at the bottom of the screen.
    CGPoint origin = CGPointMake(SCREEN_WIDTH / 2 - kGADAdSizeLeaderboard.size.width / 2
                                 ,
                                 SCREEN_HEIGHT
                                 - kGADAdSizeLeaderboard.size.height
                                 - navigationBarRect.size.height
                                 - 20);


    // Use predefined GADAdSize constants to define the GADBannerView.
    self.adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeLeaderboard origin:origin];

    // Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID before compiling.
    self.adBanner.adUnitID = kADMobBottomBannerPad;
    self.adBanner.delegate = self;
    self.adBanner.rootViewController = self;

    [self.view insertSubview:self.adBanner aboveSubview:self.scrollView];
    [self.adBanner loadRequest:[self request]];



- (GADRequest *)request
{
GADRequest *request = [GADRequest request];

// Make the request for a test ad. Put in an identifier for the simulator as well as any devices
// you want to receive test ads.
request.testDevices = @[
                        // TODO: Add your device/simulator test identifiers here. Your device identifier is printed to
                        // the console when the app is launched.
                        GAD_SIMULATOR_ID
                        ];
return request;
}  

I'm initializing Ad-Mob inside viewDidLoad. Delegate methods are set-up correctly. Am I missing something?

Thanks!

Was it helpful?

Solution

Is it a lifecycle problem? For example, say you have two views, and the user can tab between them. If the delegate for the first view is released when the second view is present, and the ad system is trying to call your first view delegate which is no-longer available you'd get a crash.

You could use NSZombie (a run option in schema settings) to detect use-after-release bugs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top