本文介绍了将谷歌地图添加为子视图会导致 iOS 应用程序崩溃并使用 exc_bad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到大约 3 天前,我的代码都运行良好.我试过回到一个 100% 工作的更旧的提交,但现在它仍然因 exc_bad 崩溃.只有在设备上运行应用程序时才会发生崩溃,如果我在模拟器上运行应用程序或使用仪器在设备上运行应用程序,它运行得非常好.当我更改我的 google api 密钥时,它说您可能没有使用此 api 密钥的权限"但不再崩溃.

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.

该应用程序仅在通过 xcode 在设备上运行该应用程序时崩溃.当稍后在设备上运行相同版本而不连接到 xcode 时,它​​可以正常工作.

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.

我不确定可以在此处添加哪些信息来帮助调试问题.我最近将 xcode 更新到 6.4,并使用最新更新更新了 OSX.

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.

我使用的是 google 1.10.1 sdk 版本,使用 CocoaPods 安装

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];

错误本身在代码=1、代码=2 和代码=257 之间变化.我尝试使用故事板而不是代码添加 GMSMapView.我尝试安装旧版本的 xcode 并再次运行,但它没有改变任何东西.

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.

推荐答案

我已经找到了问题的根源并有一个解决方法:

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

该问题似乎是由 XCode 中的 OpenGL ES Frame Capture 触发的;我猜这个问题是在 Apple 将 Metal 添加到 XCode 6.4/iOS 8.3 的组合中时开始的,也许不知何故对整个帧捕获调试系统产生了不利影响.

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.

解决方法:

  1. 在 XCode 中,转到产品 > 方案 > 编辑方案...
  2. 选择左侧的运行"标签.
  3. 选择顶部的选项"子选项卡.
  4. 将GPU 帧捕获"从自动启用"或OpenGL ES"更改为金属"或禁用".

这会禁用 OpenGL ES 帧捕获,这不是很好,但允许您继续调试您的构建.

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

不确定这个问题是 Apple 的还是 Google 的,但我会向两者发布错误报告.快乐编码!

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

--

之前的帖子:

一些进一步的信息(将其作为评论,但还没有代表),因为我也遇到了这种情况;尽我所能:

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:

  • 该问题在 XCode 6.4 和 XCode 7 beta 3 中很明显
  • 它仅在调试模式下显示自己,不在 XCode 之外运行.
  • 它不会在 iOS 8.1.2 上出现,但会在 iOS 8.3 上出现.
  • Google Maps 1.9.X(作为框架文件导入)和 1.10.X(作为 CocoaPod 导入,包括最新版本)都会发生这种情况
  • 我还不能完全验证这一点,但它没有出现在我的 XCode 6.3.2 中;这可能是因为我无法在那个版本中为 8.3 编译.

我可能会错过赃物赏金的截止日期,但我明天会花一整天的时间进行更深入的挖掘,并会回来报告.

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

这篇关于将谷歌地图添加为子视图会导致 iOS 应用程序崩溃并使用 exc_bad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 04:12