【问题标题】:GLKView display method causing crash at [GLKView _createFramebuffer]GLKView 显示方法导致 [GLKView _createFramebuffer] 崩溃
【发布时间】:2018-08-07 18:40:24
【问题描述】:

从 iOS 11 开始,当我们在 GLKView 上调用 display 方法时,我注意到 OpenGL-ES 崩溃。我们已确保 GLKView 和 EAGLContext 已正确实例化并从适当的线程调用。

以下是与崩溃相关的堆栈跟踪。

Exception Type:  SIGABRT
Exception Codes: #0 at 0x182c042e8
Crashed Thread:  0

Thread 0 Crashed:
0   libsystem_kernel.dylib               0x0000000182c042e8 __pthread_kill + 8
1   libsystem_pthread.dylib              0x0000000182d1d748     pthread_kill$VARIANT$armv81 + 356
2   libsystem_c.dylib                    0x0000000182b72fbc abort + 136
3   Metal                                0x0000000184e15a9c MTLReleaseAssertionFailure + 268
4   AppleMetalGLRenderer                 0x00000001a269af18 GLDTextureRec::allocMetalTexture() + 724
5   AppleMetalGLRenderer                 0x00000001a269b010 GLDTextureRec::loadPrivateTexture(unsigned int, unsigned short*) + 52
6   AppleMetalGLRenderer                 0x00000001a269917c GLDTextureRec::update(unsigned int, unsigned short*) + 164
7   AppleMetalGLRenderer                 0x00000001a2695e98 GLDFramebufferRec::load() + 124
8   AppleMetalGLRenderer                 0x00000001a2696224 gldLoadFramebuffer + 12
9   GLEngine                             0x00000001a345e84c gleCheckFramebufferStatus + 112
10  GLEngine                             0x00000001a340bb44 glCheckFramebufferStatusEXT_Exec + 120
11  GLKit                                0x000000018feef330 -[GLKView _createFramebuffer] + 1144
12  GLKit                                0x000000018feef660 -[GLKView _setFramebuffer:] + 128
13  GLKit                                0x000000018feef8ac -[GLKView    _display:] + 84

这是我能够重现该崩溃时得到的 Xcode 控制台输出。

GTML desc[0] t=4 f=70 w=1001 h=944 d=1 m=1 s=4 a=1 r=1 u=4
failed assertion metalTexture != nil at line 863 in allocMetalTexture

通过堆栈跟踪,看起来崩溃发生在 GLKit 为 GLKView 创建帧缓冲区对象时,然后它在 draw 方法中调用我们。我并不完全是这个问题的潜在根本原因。

不幸的是,这种崩溃很难重现并且不会持续发生。

一些重要的代码sn-ps来自代码。

设置 GLKView 和 EAGLContext:

self.eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:self.resources.shareGroup];

// Create the actual OpenGL view
self.glView = [[GLKView alloc] initWithFrame:self.frame context:self.eaglContext];
self.glView.delegate = self;
self.glView.enableSetNeedsDisplay = NO;
self.glView.contentScaleFactor = self.screenDensity;
self.glView.drawableMultisample = GLKViewDrawableMultisample4X;

[EAGLContext setCurrentContext:self.eaglContext];
//Load custom textures
[EAGLContext setCurrentContext:nil];

//Now, I created vertexArrayObjects using glGenVertexArrays, enable blending etc, setup vertexBufferObjects for vertices and indices using glGenBuffers method.

现在,当我准备好绘制内容时,我正在调用以下代码。我还进行了检查以确保使用 eaglContext、GLKView 以及与创建 EAGLContext 的位置相同的线程。

[EAGLContext setCurrentContext:self.eaglContext];
if(!CGRectIsEmpty(self.glView.bounds) && !self.hidden) {
    [self.glView display];
}
[EAGLContext setCurrentContext:nil];

据我所知,我们不需要调用 bindDrawable,因为我使用的是 GLKView 本身提供的默认帧缓冲区。

非常感谢任何见解/帮助。

【问题讨论】:

  • 请贴出相关代码
  • 嗨@Coder256。包含相关代码。

标签: ios opengl-es opengl-es-2.0 glkit glkview


【解决方案1】:

发生此崩溃是因为我试图执行 opengl 绘制操作,而应用程序处于后台或移动到后台。

问候。

【讨论】:

    【解决方案2】:

    我想这可能是内存不足(主要是 VRAM)。

    Apple 似乎使用金属纹理来表示 OpenGL FBO,因此任何 OpenGL FBO 操作都会转移到 metalTexture 操作。

    但如果内存不足,则从 FBO 数据创建的金属纹理将分配失败。

    使用监视器的良好记忆可能对您很重要。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多