From 1c12b818b3b1ca12689d7fcbb6f629dfc80bc8d0 Mon Sep 17 00:00:00 2001 From: magjed Date: Mon, 31 Jul 2017 09:11:46 -0700 Subject: [PATCH] ObjC RTCEAGLVideoVideo: Check GL context is non-nil in constructor RTCEAGLVideoVideo ensureGLContext has been observed to fail because the GL context is nil. This CL checks the GL context is non-nil in the ctor instead. BUG=b/62865840 Review-Url: https://codereview.webrtc.org/2991863002 Cr-Commit-Position: refs/heads/master@{#19189} --- .../objc/Framework/Classes/UI/RTCEAGLVideoView.m | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/webrtc/sdk/objc/Framework/Classes/UI/RTCEAGLVideoView.m b/webrtc/sdk/objc/Framework/Classes/UI/RTCEAGLVideoView.m index 89b7dfcc2e..80282f0b0b 100644 --- a/webrtc/sdk/objc/Framework/Classes/UI/RTCEAGLVideoView.m +++ b/webrtc/sdk/objc/Framework/Classes/UI/RTCEAGLVideoView.m @@ -121,7 +121,9 @@ - (instancetype)initWithFrame:(CGRect)frame shader:(id)shader { if (self = [super initWithFrame:frame]) { _shader = shader; - [self configure]; + if (![self configure]) { + return nil; + } } return self; } @@ -129,17 +131,23 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder shader:(id)shader { if (self = [super initWithCoder:aDecoder]) { _shader = shader; - [self configure]; + if (![self configure]) { + return nil; + } } return self; } -- (void)configure { +- (BOOL)configure { EAGLContext *glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; if (!glContext) { glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; } + if (!glContext) { + RTCLogError(@"Failed to create EAGLContext"); + return NO; + } _glContext = glContext; // GLKView manages a framebuffer for us. @@ -176,6 +184,7 @@ [strongSelf displayLinkTimerDidFire]; }]; [self setupGL]; + return YES; } - (void)dealloc {