6

我们正在开发一个 iPad 应用程序,从带有注释的地图视图开始。

当我们切换到另一个具有基于 opengl 的图表解决方案 (shinobi) 的视图时,通过使用故事板。返回到带有地图的视图时,在触摸地图以移动它之前没有问题。当我们尝试移动地图时,它在 [EAGLContext setCurrentContext] 处因 exc_bad_access 异常而崩溃

有任何想法吗?

这是崩溃日志的一部分:

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 ...
4

2 回答 2

7

我为 Shinobi 工作,我们一直在对此进行调查 - 部分原因是 Apple 的地图代码保留了我们的 GL-Context。作为临时解决方法,您可以创建一个 ShinobiChart 的子类,并在图表的 dealloc 方法中取消 GL 上下文,如下所示:

- (void) dealloc {
    [super dealloc];

    [EAGLContext setCurrentContext:nil]; // must be after dealloc
}

或者如果您使用的是 ARC,(因为不允许发送 dealloc):

#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

希望这会有所帮助,但请直接与我们联系 - 我们将在下一个版本中进行全面修复。

于 2012-09-28T14:09:18.393 回答
0

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 should be set on main thread.

于 2016-06-09T11:35:46.467 回答