IOS 6 MKMapView crashes with [EAGLContext setCurrentContext]

We are developing an iPad application, starting with the presentation of a map with annotations.

Using the storyboard, when we move on to another view that has a graphical solution based on opengl (shinobi). When you return to the view with the map, it does not have problems until you touch the map to move it. When we try to move the map, it fails exc_bad_access exceptions in [EAGLContext setCurrentContext]

Any ideas?

Here is part of the crash log:

OS Version: iOS 6.0 (10A403) Report Version: 104 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 0x39974b12 +[EAGLContext setCurrentContext:] + 74 1 VectorKit 0x32c64f0c -[VGLGPU setPaused:] + 120 2 VectorKit 0x32c54db8 -[VKMainLoop updateLinkState] + 492 3 VectorKit 0x32c54950 -[VKScreenCanvas _updateDisplayStatus:] + 104 4 VectorKit 0x32ccea9a -[VKScreenCanvas setGesturing:] + 254 5 MapKit 0x34defc3c -[MKMapView _willStartUserInteraction] + 48 6 MapKit 0x34de891a -[MKMapGestureController beginGesturing] + 50 7 MapKit 0x34de8c6c -[MKMapGestureController handlePan:] + 252 8 UIKit 0x379ead2c _UIGestureRecognizerSendActions + 124 9 UIKit 0x379b23d8 -[UIGestureRecognizer _updateGestureWithEvent:] + 388 10 UIKit 0x37b9f474 ... 
+6
source share
2 answers

I work at Shinobi, and we studied this - in part because of Apple code that preserves our GL-Context. As a temporary workaround, you can subclass ShinobiChart and nil-out the GL context in the chart's dealloc method, for example:

 - (void) dealloc { [super dealloc]; [EAGLContext setCurrentContext:nil]; // must be after dealloc } 

or if you use ARC, (since sending dealloc is not allowed):

 #import <ShinobiCharts/SChartCanvas.h> @interface ShinobiChartGl : ShinobiChart @end @implementation ShinobiChartGl - (void) dealloc { [self.canvas.glView removeFromSuperview]; self.canvas.glView = nil; // force glView dealloc [EAGLContext setCurrentContext:nil]; } @end 

Hope this helps, but contact us directly - we will have a full fix in our next version.

+7
source

for those who did not work, even tried [EAGLContext setCurrentContext:nil]; on dealloc try this

 dispatch_async(dispatch_get_main_queue(), ^{ [EAGLContext setCurrentContext:nil]; }); 

EAGLContext must be installed in the main thread.

0
source

Source: https://habr.com/ru/post/926314/


All Articles