41

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.

Yoav Schwartz
  • 2,017
  • 2
  • 23
  • 43
  • Check all operation regarding google map is process on main thread? if not then move on main thread and check – Gaurav Patel Jul 09 '15 at 10:59
  • 1
    I have the same issue, i've tested on an iPhone 4s with 8.3 (DID crash), iPhone 6 with 8.3 and 8.4 (didn't crash). Which iOS version is your device running? – Fantini Jul 14 '15 at 13:14
  • 1
    iphone 6 and iphone 5 with 8.4. – Yoav Schwartz Jul 14 '15 at 14:28
  • 1
    weird, I have an iPhone 6 with 8.4 and works just fine – Fantini Jul 14 '15 at 15:23
  • I have managed to make it work in the meantime by deleting xcode, going back to xcode 6.3.2, restarting the device and re-pulling the repo. Basically I just tried to restart everything – Yoav Schwartz Jul 14 '15 at 15:30
  • How you have declared GMSMapView , retain or Strong – Arpit B Parekh Jul 15 '15 at 10:51
  • See this link http://stackoverflow.com/questions/23605476/app-crash-when-pressing-a-button-in-a-subview – Arpit B Parekh Jul 15 '15 at 10:55
  • I have in fact tried it 3 different ways. first as a strong property initialised in viewDidLoad, second I tried with connecting from the storyboard as a strongly referred IBOutlet and the third I tried letter to letter from the google get started guide using a variable – Yoav Schwartz Jul 15 '15 at 11:59
  • Did it Worked for you ? Its not working for me, I Tried it... I Tired to do it Metal, Open GLES & Disabled as well.... what to do with Metal API Validation ? – Mohit Oct 24 '16 at 11:07
  • The accepted solution worked for me like magic. you might be facing a different issue? – Yoav Schwartz Oct 25 '16 at 15:11

3 Answers3

106

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!

Dharman
  • 30,962
  • 25
  • 85
  • 135
Dave Cole
  • 2,446
  • 2
  • 20
  • 26
  • 3
    I posted the bug to Google here: https://code.google.com/p/gmaps-api-issues/issues/detail?id=8303&q=apitype%3AIosSDK%20type%3ADefect&sort=-stars&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Internal%20Stars – Dave Cole Jul 24 '15 at 20:08
1

This happened to mee too when I was using the Google Maps SDK. I filed a bug report as after restarting Xcode and deleting the project and reinstalling it, it worked perfectly fine.

This is not your problem, but simply a bug. If you install the build through test flight or the App Store it will work like a charm.

For debugging, just keep restarting Xcode and if possible try to run it through Xcode 7. There's a chance they fixed this bug.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Julian E.
  • 4,687
  • 6
  • 32
  • 49
1

Try assigning the mapView.delegate only after insertSubview of the mapView into your view hierarchy.

I am experiencing something similar and I suspect it to be a bug with Xcode 6.4 as Julian alludes to above.

Dharman
  • 30,962
  • 25
  • 85
  • 135
MarineHero
  • 143
  • 2
  • 5
  • I can't seem to comment or reply due to lack of rep points, but wanted to ask Yoav Schwartz if he tried assigning the **mapView.delegate** only **after** adding/inserting the mapView into his view hierarchy? James Pereira/@marinehero – Julian E. Jul 15 '15 at 17:06
  • I have not tried that, but also the problem kind of solved itself and I really don't know how or why. Just reinstalling xcode. – Yoav Schwartz Jul 16 '15 at 07:23