Switch Google Maps SDK & Mapkit in the same app cause crash

二次信任 提交于 2019-11-29 23:47:12

问题


I created a pretty simple app that uses MapKit and GoogleMaps frameworks and tried to switch between the two maps. I am using ARC (ios 6.1) and Google Maps SDK for iOS version: 1.1.1.2311. After a couple of switches the app crashes with [EAGLContext setCurrentContext:] – always in the MapKit code. There was some suggestions in a previous thread - to try setting [EAGLContext setCurrentContext:nil] at various places but it doesn’t help.

stack trace:
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000c
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   OpenGLES                        0x33beeb12 +[EAGLContext setCurrentContext:] + 74
1   VectorKit                       0x383cada4 -[VGLGPU setPaused:] + 120
2   VectorKit                       0x383bad70 -[VKMainLoop updateLinkState] + 492
3   VectorKit                       0x383c7334 -[VKAnimation startWithStepHandler:completionHandler:] + 112
4   VectorKit                       0x383d657a -[VKBuildingFootprintMapModel _reloadStyleAnimated:] + 474
5   VectorKit                       0x383d6398 -[VKBuildingFootprintMapModel setActive:] + 84
6   VectorKit                       0x383d5ef4 -[VKModelObject setSupermodel:] + 44
7   VectorKit                       0x383d624a -[VKModelObject insertSubmodel:atIndex:] + 142
8   VectorKit                       0x383d615a -[VKMapRasterizer addSubmodel:] + 322
9   VectorKit                       0x383d5cb4 -[VKMapModel addSubmodel:] + 136
10  VectorKit                       0x383cf1c4 -[VKMapModel forceMapType:] + 1532
11  VectorKit                       0x383cc568 -[VKMapModel initWithTransform:shouldRasterize:] + 2016
12  VectorKit                       0x383cbd80 -[VKMapModel initShouldRasterize:] + 36
13  VectorKit                       0x383c9678 -[VKMapCanvas initWithFrame:shouldRasterize:] + 356
14  VectorKit                       0x383c930e -[VKMapView initWithFrame:andGlobe:shouldRasterize:] + 642
15  MapKit                          0x33599320 -[MKMapView _commonInitAndEnableLoading:fromIB:] + 720
16  MapKit                          0x33598e9c -[MKMapView initWithFrame:] + 252
17  saTest                          0x00017e2a -[AppleMapCtl loadView] (AppleMapCtl.m:27)

回答1:


We were having the same issues after first integrating Google Maps into our iOS app. The solution that seems to work for us so far has been to wait some period of time after releasing the GMSMapView and all related Google Maps objects, prior to instantiating any MapKit objects.

Based on our testing to thus far, our thought is that the GMSMapView object hierarchy is released asynchronously, and doesn't seem to aggressively re-establish its EAGLContext as "current" prior to releasing OpenGL resources. So if MapKit switches the current EAGLContext, then the GMSMapView hierarchy proceeds with releasing resources, you get a cross pollination of OpenGL resource release.

So our steps are:

  1. Release GMSMapView, and all GMS related objects
  2. Wait 100ms (0.1 sec)
  3. Set the EAGLEContext to nil
  4. Allocate MKMapView and proceed.

So far this has worked for us. Good luck.



来源:https://stackoverflow.com/questions/15442119/switch-google-maps-sdk-mapkit-in-the-same-app-cause-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!