Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

objective c - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...