首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在[GLKView _createFramebuffer]上导致崩溃的GLKView显示方法

在[GLKView _createFramebuffer]上导致崩溃的GLKView显示方法
EN

Stack Overflow用户
提问于 2018-02-28 08:30:52
回答 2查看 682关注 0票数 0

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

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

代码语言:javascript
复制
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控制台输出。

代码语言:javascript
复制
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回调draw方法之前,似乎是在为GLKView创建帧缓冲区对象时发生了崩溃。我并不完全是这个问题的潜在根源。

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

代码中的一些重要代码片段。

设置GLKView和EAGLContext:

代码语言:javascript
复制
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的位置使用相同的线程。

代码语言:javascript
复制
[EAGLContext setCurrentContext:self.eaglContext];
if(!CGRectIsEmpty(self.glView.bounds) && !self.hidden) {
    [self.glView display];
}
[EAGLContext setCurrentContext:nil];

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

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

EN

回答 2

Stack Overflow用户

发布于 2019-07-27 09:04:21

这个崩溃的发生是因为我试图执行opengl绘图操作,而应用程序在后台或移动到后台。

致以问候。

票数 1
EN

Stack Overflow用户

发布于 2019-06-14 11:42:19

我认为这可能即将耗尽内存(主要是VRAM)。

苹果似乎使用金属纹理来表示OpenGL FBO,所以任何OpenGL FBO操作都将转移到metalTexture操作。

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

也许一个好的内存使用监视器对你来说很重要。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49020160

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档