Closed zhaxun closed 4 years ago
修改 CCEAGLView-ios.mm文件
(void) swapBuffers { // IMPORTANT: // - preconditions // -> context MUST be the OpenGL context // -> renderbuffer must be the RENDER BUFFER if([EAGLContext currentContext] != _context){ if(![EAGLContext setCurrentContext:_context]){ NSLog(@"can not set current context"); } } if (_multisampling) { / Resolve from msaaFramebuffer to resolveFramebuffer / //glDisable(GL_SCISSOR_TEST); glBindFramebuffer(GL_READ_FRAMEBUFFER_APPLE, _msaaFramebuffer); glBindFramebuffer(GL_DRAW_FRAMEBUFFER_APPLE, _defaultFramebuffer); glResolveMultisampleFramebufferAPPLE(); }
CHECK_GL_ERROR();
if (_discardFramebufferSupported)
{
if (_multisampling)
{
if (_depthFormat)
{
GLenum attachments[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT};
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments);
}
else
{
GLenum attachments[] = {GL_COLOR_ATTACHMENT0};
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 1, attachments);
}
}
else if (_depthFormat)
{
// not MSAA
GLenum attachments[] = { GL_DEPTH_ATTACHMENT};
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments);
}
CHECK_GL_ERROR();
}
glBindRenderbuffer(GL_RENDERBUFFER, _defaultColorBuffer);
if(![_context presentRenderbuffer:GL_RENDERBUFFER]) NSLog(@"cocos2d: Failed to swap renderbuffer in %s\n", FUNCTION);
CHECK_GL_ERROR();
// We can safely re-bind the framebuffer here, since this will be the
// 1st instruction of the new main loop
if(_multisampling)
glBindFramebuffer(GL_FRAMEBUFFER, _msaaFramebuffer);
}
进入后切回前台时crash的解决办法:
修改AppDelegate.cpp文件 void AppDelegate::applicationDidEnterBackground() { EventDispatcher::dispatchEnterBackgroundEvent(); renderer::BaseRenderer::enterback = 30;//设置进入后台时设置延迟渲染帧数 }
修改RenderFlow.cpp,延迟去渲染! void RenderFlow::render(NodeProxy* scene, float deltaTime) { // CCLOG("RenderFlow::render: %d deltaTime:%.4f", BaseRenderer::enterback,deltaTime); if(BaseRenderer::enterback > 0){ BaseRenderer::enterback -= 1; return; }
【当前现象】 1、直播推流接入时,第一次启动授权后,会闪退一次(必现) 2、直播停止时,调用stopPreview会导致opengl报错 _2019-12-24 15:36:20.035934+0800 Live-mobile[3491:1387562] [I][TXLivePush.m, stopPreview, 818]:liteav_api 0x280398410 stopPreview 2019-12-24 15:36:20.178709+0800 Live-mobile[3491:1387562] [I][TXCRenderViewiOS.m, dealloc, 362]:TXCRenderView dealloc:0x107c175e0 OpenGL error 0x0502 in -[CCEAGLView swapBuffers] 406 OpenGL error 0x0500 in -[CCEAGLView swapBuffers] 432
【集成包】 基础版Smart cocos creator2.2
【复现概率】 必现
【复现途径】
【相关附件】 调起方法:mViewController.view为cocos引擎的根视图 CGRect bounds = [[UIScreen mainScreen] bounds]; _pushView = [[CameraPushView alloc] initWithFrame:bounds]; [[mViewController.view viewWithTag:10] addSubview:_pushView]; 提供方法:
(NSString )startPush:(NSString )param Callback:(NSString *)callback { if(_pushView){ [_pushView startPush]; } return @""; }
(NSString )pausePush:(NSString )param Callback:(NSString *)callback { if(_pushView){ [_pushView pausePush]; } return @""; }
(NSString )resumePush:(NSString )param Callback:(NSString *)callback { if(_pushView){ [_pushView resumePush]; } return @""; }
(NSString )stopPush:(NSString )param Callback:(NSString *)callback { if(_pushView){ [_pushView stopPush]; } return @""; }
(NSString )stop:(NSString )param Callback:(NSString *)callback { if(_pushView){ [_pushView stopPreview]; // [_pushView removeFromSuperview]; _pushView = nil; } return @""; }
CameraPushView接口(就是将CameraPushViewController修改为UIView):
请在附件中添加相关视频、日志,截图、操作视频等