美文网首页
GPUImage presentBufferForDispla

GPUImage presentBufferForDispla

作者: Callmewenxi | 来源:发表于2017-09-21 22:26 被阅读306次

项目中使用GPUImage自定义相机录制短视频,测试发现锁屏后再进入App会Crash,每次都崩溃在以下代码:

- (void)presentBufferForDisplay;
{
    [self.context presentRenderbuffer:GL_RENDERBUFFER];
}

在 GPUImage的Issues#197找到了答案,大概原因是iOS不支持后台进行OpenGL渲染,所以切后台之前要调用glfinish(),将缓冲区中的指令(无论是否为满)立刻送给图形硬件执行,glfinish()会等待图形硬件执行完才返回。

- (void)observeGlobalNotifications
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onApplicationWillResignActive) name:UIApplicationWillResignActiveNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onApplicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
}

- (void)unobserveGlobalNotifications
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
}

- (void)onApplicationWillResignActive
{     
    //[self.camera pauseCameraCapture];
    [self.camera stopCameraCapture];

    runSynchronouslyOnVideoProcessingQueue(^{
        glFinish();
    });
}

- (void)onApplicationDidBecomeActive
{
   // [self.camera resumeCameraCapture];
    [self.camera startCameraCapture];
}

相关文章

  • GPUImage presentBufferForDispla

    项目中使用GPUImage自定义相机录制短视频,测试发现锁屏后再进入App会Crash,每次都崩溃在以下代码: 在...

  • GPUImage2 的导入

    首先,GPUImage有3个版本分别是:GPUImage,GPUImage2,GPUImage3 GPUImage...

  • GPUImage概览

    读GPUImage源码,深入了解GPUImage原理及OpenGL ES。 关于GPUImage GPUImage...

  • GPUImage 解析

    GPUImage解析(一) —— 基本概览(一)GPUImage解析(二) —— 基本概览(二)GPUImage解...

  • GPUImage架构-思维导图

    GPUImage架构 参考文章: GPUImage架构

  • 视频滤镜

    GPUImage原生美颜 GPUImage原生美颜 步骤一:使用Cocoapods导入GPUImage步骤二:创建...

  • iOS GPUImage blog收集

    iOS GPUImage blog收集 GPUImage详解(简书博客) GPUImage(五):五种类型输入源(...

  • GPUImage(四):GPUImageFramebuffer

    GPUImage概览GPUImage(一):视频采集GPUImageVideoCameraGPUImage(二):...

  • iOS-DIY美颜相机

    本例是使用GPUImage开源框架,生成美颜相机。实时采集画面,进行美颜。 GPUImage GPUImage是开...

  • GPUImage源码分析与使用(一)

    GPUImage简介 GPUImage是链式编程,可以处理图片和视频,支持iOS和Mac。 GPUImage1.0...

网友评论

      本文标题:GPUImage presentBufferForDispla

      本文链接:https://www.haomeiwen.com/subject/qhztextx.html