GAIThread Crash

497 views
Skip to first unread message

MattH

unread,
Jun 17, 2016, 6:06:43 PM6/17/16
to Google Mobile Ads SDK Developers
I've pasted the relevant portion of a crash log I received from a TestFlight tester. I haven't been able to reproduce the crash myself. Is it correct that Google Analytics is the cause? I don't understand why that's in my project when I'm only using GoogleMobileAds v7.8.1, not Analytics. Can someone please help me resolve this or let me know how to remove whatever is causing this without getting rid of AdMob?

Report:

Date/Time:          2016-06-12 15:54:31.31 +0200
Launch Time:        2016-06-12 15:48:27.27 +0200
OS Version:          iOS 9.3.2 (13F69)
Report Version:      105

Exception Type:  00000020
Exception Codes: 0x000000008badf00d
Exception Note:  SIMULATED (this is NOT a crash)
Highlighted by Thread:  2

Application Specific Information:
<BKNewProcess: 0x157d24200; com.my.app; pid: 6149; hostpid: -1> has active assertions beyond permitted time:
{(
    <BKProcessAssertion: 0x157d27f70> id: 6149-C54C89BC-350A-4A17-B85C-E0E6CA9BBC4D name: Called by UIKit, from <redacted> process: <BKNewProcess: 0x157d24200; com.my.app; pid: 6149; hostpid: -1> permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:6149 preventSuspend  preventIdleSleep  preventSuspendOnSleep
)}

Elapsed total CPU time (seconds): 8.780 (user 8.780, system 0.000), 7% CPU
Elapsed application CPU time (seconds): 0.488, 0% CPU

Thread 2 name:  GAIThread
Thread 2:
0  libsystem_kernel.dylib        0x0000000180a80fd8 mach_msg_trap + 8
1  libsystem_kernel.dylib        0x0000000180a80e54 mach_msg + 72
2  CoreFoundation                0x0000000180eb8c60 __CFRunLoopServiceMachPort + 196
3  CoreFoundation                0x0000000180eb6964 __CFRunLoopRun + 1032
4  CoreFoundation                0x0000000180de0c50 CFRunLoopRunSpecific + 384
5  Foundation                    0x00000001817f0cfc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 308
6  Foundation                    0x0000000181846030 -[NSRunLoop(NSRunLoop) run] + 88
7  THD                          0x00000001002c62bc 0x1000f0000 + 1925820
8  Foundation                    0x00000001818d7e4c __NSThread__start__ + 1000
9  libsystem_pthread.dylib      0x0000000180b67b28 _pthread_body + 156
10  libsystem_pthread.dylib      0x0000000180b67a8c _pthread_body + 0
11  libsystem_pthread.dylib      0x0000000180b65028 thread_start + 4

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Jun 20, 2016, 10:45:20 AM6/20/16
to Google Mobile Ads SDK Developers
Hi there,

We are going to need you to provide more information for us to investigate further.
  • Can you provide us with a code snippet / project that experience this crash?
  • Can you also provide us the steps on how to recreate this problem, as well as logs from Charles Proxy?
  • What version of the SDK are you using? And what iOS versions are receiving this crash? 
  • Are you using any Mediation? If so, let us know more about that as well.
Regards,
Joshua Lagonera
Mobile Ads SDK Team

MattH

unread,
Jun 20, 2016, 8:27:01 PM6/20/16
to Google Mobile Ads SDK Developers
Hi Joshua,

Thank you for your reply. The crash my tester is experiencing is unfortunately difficult to pin-point, as they say it happens randomly during gameplay. I haven't been able to encounter it myself, so I'm unable to provide steps or relevant sample code for you.

I'm new to development and have never used Charles Proxy before, but would its logs be useful if I don't experience the crash?

I'm using SDK 7.8.1 and the tester's device is iPad Air running iOS 9.3.2

The AdMob Network (optimized) is the only mediation ad source for my 2 ad units. I'm not linked to Firebase and don't have promotions.

I have 1 interstitial ad that is displayed after the game over menu is shown. My smart banner ad is shown on the main menu and when the game over and level complete menus are shown. I don't have the banner displayed during gameplay, which is when the tester is experiencing crashes.

The tester just informed me that they disabled ads via my IAP at the start of testing, so all crashes have occurred with ads disabled. All of my code to display ads are inside if statements which check the variable tied to the IAP.

Sorry for not being able to provide better information. If you can't help as a result, is there anything I can disable or remove that I'm not using anyway? Or does the crash log not highlight a certain aspect of the SDK that is likely the cause?

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Jun 21, 2016, 11:55:37 AM6/21/16
to Google Mobile Ads SDK Developers
Hello there,

You stated that you are "disabling" the ads when ads are disabled via IAP. How exactly are you disabling them? Do you pre-load them and not show them when you have IAP ads disabled?
Can you show us the code snippet on your implementation on how you are disabling the ads?

Regards,
Joshua Lagonera
Mobile Ads SDK Team.

MattH

unread,
Jun 21, 2016, 6:40:02 PM6/21/16
to Google Mobile Ads SDK Developers
In my AppDelegate:

if (![GameData sharedGameData].adsAreRemoved) {

   
[[MyAdMobController sharedController] loadBannerView];

   
[[MyAdMobController sharedController] loadInterstitial];

}


Those methods:


- (void)loadBannerView {

   
if (bannerView_ != nil) {
       
return;
   
}

    bannerView_
= [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait origin:CGPointMake(0, 0)];

    bannerView_
.adUnitID = MY_BANNER_ID;

    bannerView_
.rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;

    bannerView_
.delegate = self;

   
[bannerView_ loadRequest:[GADRequest request]];
}
- (void)loadInterstitial {

   
if ( interstitial_ != nil ) {

        interstitial_
= nil; //clean interstitial for reloading
   
}
    interstitial_
= [[GADInterstitial alloc] initWithAdUnitID:MY_INTERSTITIAL_ID];

    interstitial_
.delegate = self;

   
[interstitial_ loadRequest:[GADRequest request]];
}


In my main menu class:


if (![GameData sharedGameData].adsAreRemoved) {

   
[[MyAdMobController sharedController] addBannerToView:[CCDirector sharedDirector].view];

}


And when they go from the main menu to my gameplay class:


if (![GameData sharedGameData].adsAreRemoved) {

   
[[MyAdMobController sharedController] removeBanner];

}


Those methods (I also show the banner in my gameplay class after a game over or level complete occurs, and remove it once they start another or continue a game):

- (void)addBannerToView:(UIView *)view {

   
if (bannerView_ != nil) {
       
[view addSubview:bannerView_];
   
}
   
else
   
{
       
[self loadBannerView];
   
}
}
- (void)removeBanner {

 
[bannerView_ removeFromSuperview];

}


In my gameplay class when they get a game over:


if (![GameData sharedGameData].adsAreRemoved) {

   
[[MyAdMobController sharedController] showInterstitialOnViewController:rootViewController];

}


And that method:


- (void)showInterstitialOnViewController:(UIViewController *)viewController {

   
if (interstitial_ != nil && [interstitial_ isReady]) {

       
[interstitial_ presentFromRootViewController:viewController];

   
}
   
else
   
{
       
if ([self.delegate respondsToSelector:@selector(MyInterstitialNotLoaded)]) {

           
[self.delegate MyInterstitialNotLoaded];

       
}

       
if (interstitial_ == nil) {

           
[self loadInterstitial];

       
}

   
}

}


And this method gets called when the IAP is bought:


- (void)doRemoveAds {

   
[[MyAdMobController sharedController] removeBanner];

   
[GameData sharedGameData].adsAreRemoved = YES;

    _removeAdsButton
.enabled = NO;

}

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Jun 22, 2016, 9:57:21 AM6/22/16
to Google Mobile Ads SDK Developers
Hi,

Your implementation seems to be correct. However, we suggest that you not load your banner and interstitial ads at the same time.
Moving forward, this look like a confirmed issue with Google Analytics. I suggest that you follow this thread about your issue.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

MattH

unread,
Jun 22, 2016, 5:56:48 PM6/22/16
to Google Mobile Ads SDK Developers
Yeah, I saw that thread, but thought it was strange that I was affected by it since I don't have the separate Analytics SDK in my project. So it's too deeply integrated with GoogleMobileAds to remove? Is there an older SDK version which doesn't have the issue, that I could ship with my game until it gets fixed?

Thanks for your help!

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Jun 23, 2016, 9:26:31 AM6/23/16
to Google Mobile Ads SDK Developers
Hi,

We do not recommend using an outdated version of the SDK. 
However, if you're using the Firebase SDK, you can exclude it and Analytics by using only the Mobile Ads SDK:

# Use:
pod 'Google-Mobile-Ads-SDK'

# Instead of:
pod 'Firebase/Core'
pod 'Firebase/AdMob'

Regards, 
Joshua Lagonera
Mobile Ads SDK Team

MattH

unread,
Jun 23, 2016, 6:28:46 PM6/23/16
to Google Mobile Ads SDK Developers
I added GoogleMobileAds to my project manually with the SDK download, does that have Firebase and Analytics excluded?

I'm now seeing on the Get Started page that a minimum deployment target of iOS 7 is now a prerequisite. I coded my project to be compatible for iOS 6 as my deployment target :( Do I have to change it?

MattH

unread,
Jun 23, 2016, 11:44:28 PM6/23/16
to Google Mobile Ads SDK Developers
This is off-topic, but I just tested my game on an ipod touch 4 with iOS 6.1.6 and am getting this error:

<Google> You must set the rootViewController property of <GADBannerView: 0x1edd2f60; frame = (0 0; 320 50); clipsToBounds = YES; layer = <CALayer: 0x1edd3ed0>> before loading a request.


As you can see in my above post, I do set this property like so:


bannerView_.rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;

But an NSLog check revealed that bannerView_.rootViewController was null. This doesn't happen on my ipod touch 6 iOS 9 device. Do you know how I can fix this?
Message has been deleted

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Jun 24, 2016, 8:10:28 AM6/24/16
to Google Mobile Ads SDK Developers
Hi,

Yes, the standalone Google Mobile Ads SDK does not have Firebase and Analytics included, and supports iOS 6+, so you don't have to change your deployment target. The Getting Started page only recommends iOS 7+ because of the Firebase SDK.
May we ask what version of xCode are you using?

Moving forward, I would assume you are using Storyboards and XIBs as your UI. You can fetch the rootViewController by using:

bannerview_.rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;

If your root view is embedded in a Navigation Controller, you can use:

UINavigationController *navCon = (UINavigationController *)[UIApplication sharedApplication].delegate.window.rootViewController;
bannerview_.rootViewController = [navCon.viewControllers objectAtIndex:0];

Regards,
Joshua Lagonera
Mobile Ads SDK Team

MattH

unread,
Jun 24, 2016, 5:31:26 PM6/24/16
to Google Mobile Ads SDK Developers
I'm using Xcode 7.3.1, and built my project using SpriteBuilder 1.4.9

Thanks so much, your first code example fixed the banner issue.
Reply all
Reply to author
Forward
0 new messages