ios - 同一应用中的 Google Maps SDK 和 Mapkit 导致崩溃

标签 ios mapkit google-maps-sdk-ios

试图让用户在我的应用程序中选择谷歌地图 (sdk) 和苹果 map (mapkit)。 该应用程序未使用 ARC。 崩溃场景(ios 6.0/6.1): 1. 进入谷歌地图(模态 Controller )。 2. 退出谷歌地图(关闭模式)。 3.将我的应用更改为苹果 map (mapkit)。 4.进入apple maps(modal controller)。

应用程序崩溃,我得到: [EAGLContext setCurrentContext:]

如果我不在 dealloc 中释放 google maps,则不会发生错误,但它可能会导致内存泄漏。 我在 viewDidLoad 中保留 map 并在 dealloc 中释放 map 。

有人可以帮忙吗? 谢谢, 汤姆

更详细的堆栈跟踪:

1   0x0a041324 in -[VGLGPU init] ()
2   0x0a041032 in __24+[VGLGPU sharedInstance]_block_invoke_0 ()
3   0x03b52014 in _dispatch_client_callout ()
4   0x03b4409f in dispatch_once_f ()
5   0x03b44061 in dispatch_once ()
6   0x0a040fef in +[VGLGPU sharedInstance] ()
7   0x09fab26b in -[VKMainLoop updateLinkState] ()
8   0x09fabb02 in -[VKMainLoop removeCanvas:] ()
9   0x09f9f2aa in -[VKScreenCanvas _updateDisplayStatus:] ()
10  0x09f9f3fb in -[VKScreenCanvas setNeedsDisplay] ()
11  0x027bc03d in -[UIView initWithFrame:] ()
12  0x09f75658 in -[VGLScreenCanvas initWithFrame:context:] ()
15  0x09f907e7 in -[VKMapCanvas initWithFrame:shouldRasterize:] ()
16  0x09f8982e in -[VKMapView initWithFrame:andGlobe:shouldRasterize:] ()
17  0x0267d1a1 in -[MKMapView _commonInitAndEnableLoading:fromIB:] ()
18  0x0267da9c in -[MKMapView initWithCoder:] ()
19  0x02aa8a02 in UINibDecoderDecodeObjectForValue ()
47  0x028671a7 in -[UIViewController presentModalViewController:animated:] ()

最佳答案

适用于 iOS 的 Google Maps SDK 和使用 Apple Maps 的 MapKit 都使用了 OpenGL。

适用于 iOS 的 Google Maps SDK 存在一些问题,如果意外的 OpenGL 上下文处于事件状态,这些问题可能会导致其崩溃:

http://code.google.com/p/gmaps-api-issues/issues/detail?id=4752

似乎 MapKit 在 OpenGL 上下文中也有一些问题:

iOS 6 app crashes in EAGLContext when displaying maps

您可能需要进行一些反复试验,看看是否可以找到解决问题的方法。尝试在您对 map 执行操作之前和/或之后清除当前上下文(例如当您发布 Google map 时):

[EAGLContext setCurrentContext:nil]

您也可以尝试在执行操作之前保存之前的上下文,然后再恢复它,例如:

EAGLContext* previousContext = [EAGLContext currentContext];

// Perform map operation here.

[EAGLContext setCurrentContext: previousContext];

当我调查适用于 iOS 的 Google Maps SDK 的问题时,我基本上尝试了这些方法的各种组合,直到找到有效的方法。祝你好运!

关于ios - 同一应用中的 Google Maps SDK 和 Mapkit 导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15052952/

相关文章:

ios - 苹果 map 和 MapKit 使用相同的 API 吗?

iphone - 计算 map 图钉

android - AndroidRuntime:重要异常(exception):androidmapsapi-ZoomTableManager

ios - Google Maps SDK iOS - 防止 map 在缩放时更改位置

javascript - 聆听点击和拖动的值并相应地运行

ios - 对于UIButton如何通过@selector传递多个参数

ios - 检查定时器是否正在运行

ios - 这是什么错误信息? ( objective-C )

ios - CLFloor 返回水平 2146959360?

ios - 如何解析谷歌地图的纬度和经度?