尝试让用户在我的应用程序中选择google地图(sdk)和苹果地图(mapkit)。应用程序未使用ARC。崩溃场景(ios 6.0 / 6.1):1.进入google地图(模态控制器)。2.退出谷歌地图(关闭模式)。3.在我的应用程序中更改为苹果地图(mapkit)。4.进入苹果地图(模态控制器)。
应用程序崩溃,我得到: EAGLContext setCurrentContext:
如果我不在dealloc中发布google地图,这个错误就不会发生,但它可能会导致内存泄漏。我将贴图保留在viewDidLoad中,并在取消分配时释放贴图。
有人能帮上忙吗?谢谢,Tomer
更详细的堆栈跟踪:
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:] ()
发布于 2013-02-27 00:16:49
用于iOS的Google Maps SDK和使用Apple Maps的MapKit都使用OpenGL。
Google Maps SDK for iOS存在一些问题,如果意外的OpenGL上下文处于活动状态,这些问题可能会导致它崩溃:
http://code.google.com/p/gmaps-api-issues/issues/detail?id=4752
看起来MapKit在OpenGL上下文方面也有一些问题:
iOS 6 app crashes in EAGLContext when displaying maps
您可能需要进行一些反复试验,看看是否可以找到一种方法来解决这个问题。尝试在对地图执行操作之前和/或之后(例如,在释放Google map时)清除当前上下文:
[EAGLContext setCurrentContext:nil]
您还可以尝试在执行操作之前保存以前的上下文,然后在执行操作后再次恢复它,例如:
EAGLContext* previousContext = [EAGLContext currentContext];
// Perform map operation here.
[EAGLContext setCurrentContext: previousContext];
当我调查Google Maps SDK for iOS的问题时,我基本上尝试了不同的组合,直到我发现了一些可以工作的东西。祝好运!
发布于 2013-03-03 07:26:49
当我尝试在苹果和谷歌地图之间切换时,我也遇到了同样的问题。经过多次实验,我也追踪到了发布谷歌地图和在MapKit中崩溃的交互。没有使用EAGLContext的setCurrentContext:nil调用在其他调用中,或者在发布谷歌地图之后,如建议的那样将会有所帮助。但在我的例子中,它总是重新绘制完整的苹果地图,带有注释和覆盖,然后在同一个EAGLContext setCurrentContext: call中崩溃。
基于这些知识,我能够通过在MapKit协议方法mapViewDidFinishLoadingMap中添加EAGLContext setCurrentContext:nil调用来解决我的问题(至少看起来是这样)。
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView
{
[EAGLContext setCurrentContext:nil];
}
我现在可以愉快地来回切换了。
哦,我不会在这个项目上使用ARC的。
发布于 2013-02-25 07:59:17
这可能与不使用ARC有关。在getting started部分中,他们总是提到要确保启用了use ARC。
https://stackoverflow.com/questions/15052952
复制相似问题