Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding google maps as subview crashes iOS app with exc_bad

I have code that worked perfectly fine until around 3 days ago. I have tried going back to a much older commit that worked a 100% and still now it crashes with exc_bad. The crash only happens when running the app on the device, If I run the app on the simulator or use instruments to run the app on the device it runs perfectly fine. When I changed my google api key, it said "You might not have permission to use this api key" but no longer crashed.

The app only crashes when running the app on the device via xcode. When later running the same version on the device without being connected to xcode it works fine.

I am not sure what information I can add here to help debug the problem. I have recently updated xcode to 6.4 and updated the OSX with the latest update.

I am using google 1.10.1 sdk version, installed using CocoaPods

The code I use to add the map:

self.mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];  self.mapView.myLocationEnabled = YES; self.mapView.settings.myLocationButton = YES; self.mapView.delegate = self;  [self.mapView addObserver:self                forKeyPath:@"myLocation"                   options:NSKeyValueObservingOptionNew                   context:NULL];  [self.view insertSubview:self.mapView atIndex:1]; 

The error itself varies between code=1, code=2, and code=257. I have tried adding the GMSMapView with storyboard instead of code. I have tried installing an older version of xcode and running again but it doesn't change anything.

If I comment out the insert subview line, that app doesn't crash. I have tried running the zombie instrument tool but when I run using instruments the app works fine.

#0  0x0000000100c5dc34 in EAGLContext_renderbufferStorageFromDrawable(EAGLContext*, objc_selector*, unsigned long, id<EAGLDrawable>) () #1  0x00000001002404c0 in gmscore::renderer::ios::GLRenderTarget::CreateFramebuffer() () #2  0x00000001002403cc in gmscore::renderer::ios::GLRenderTarget::FrameStart() () #3  0x00000001002e7af4 in gmscore::renderer::EntityRenderer::Draw(bool) () #4  0x00000001002516f4 in -[GMSPhoenixRenderer drawIfNeeded] () #5  0x00000001002329a0 in -[GMSEntityRendererView draw] () #6  0x000000010028dc74 in -[GMSDisplayLink displayLinkFired:] () #7  0x0000000100c5ca9c in -[DYDisplayLinkInterposer forwardDisplayLinkCallback:] () #8  0x00000001887f629c in CA::Display::DisplayLinkItem::dispatch() () #9  0x00000001887f6134 in CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) () #10 0x00000001855d1470 in IODispatchCalloutFromCFMessage () #11 0x00000001843c2dc4 in __CFMachPortPerform () #12 0x00000001843d7a54 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ () #13 0x00000001843d79b4 in __CFRunLoopDoSource1 () #14 0x00000001843d5934 in __CFRunLoopRun () #15 0x00000001843012d4 in CFRunLoopRunSpecific () #16 0x000000018db1f6fc in GSEventRunModal () #17 0x0000000188ec6fac in UIApplicationMain () #18 0x000000010002d794 in main at /Users/yoavschwartz/Documents/donkey_republic_ios/DonkeyRepublic/DonkeyRepublic/main.m:14 #19 0x0000000196272a08 in start () 

This problem seemed to have solved itself when restarting computer/device and now popped again. I really don't understand what's going on.

like image 304
Yoav Schwartz Avatar asked Jul 07 '15 09:07

Yoav Schwartz


People also ask

Why does Google Maps keep crashing on iPhone?

If the Google Maps app on your phone or tablet crashes or has other issues that affect your experience on Maps, try the following steps: Update Google Maps. Clear storage in the Settings app on your device.

Can you install Google Maps on iOS?

To download Google Maps for iPhone or iPad, make sure your phone or tablet is on iOS 13.4 and above. Download the latest version of the Google Maps app from the Apple App Store.

Why Does My Maps app keep crashing?

Restart Your Device If the issue persists, you can try restarting your device as well. Sometimes, apps and processes running in the background can interfere with Google Maps and cause it to crash. Restarting your device will help close such processes and also fix any minor glitches along the way.


1 Answers

EDIT: I've found the root of the problem and have a workaround:

The problem seems to be triggered by OpenGL ES Frame Capture in XCode; I'm guessing this problem started when Apple added Metal to the mix as of XCode 6.4/iOS 8.3, perhaps somehow adversely affecting the entire frame capture debugging system.

The workaround:

  1. In XCode, go to Product > Scheme > Edit Scheme...
  2. Select the "Run" Tab on the left.
  3. Select the "Options" sub-tab on the top.
  4. Change "GPU Frame Capture" from "Automatically Enabled" or "OpenGL ES" to either "Metal" or "Disabled".

This disables OpenGL ES frame capture, which isn't great, but allows you to continue debugging your builds.

Not sure if this issue is Apple's or Google's but I'll be posting bug reports to both. Happy coding!

--

earlier post:

Some further info (would make this a comment but don't have the rep quite yet) as I'm experiencing this too; as best I can tell:

  • The issue is apparent in XCode 6.4 as well as XCode 7 beta 3
  • It presents itself in debug mode only, not running outside XCode.
  • It doesn't manifest on iOS 8.1.2 but it does on iOS 8.3.
  • It happens with both Google Maps 1.9.X (imported as a Framework file) as well as 1.10.X (imported as a CocoaPod, including the latest)
  • I can't verify this completely yet but it hasn't shown up in XCode 6.3.2 for me; this might be because I can't compile for 8.3 in that version.

I'll likely miss the deadline for the swag bounty but I'm spending all day tomorrow digging deeper and will report back.

like image 161
Dave Cole Avatar answered Sep 28 '22 20:09

Dave Cole