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}
This commit is contained in:
magjed
2017-07-31 09:11:46 -07:00
committed by Commit Bot
parent ed8ceb61e6
commit 1c12b818b3

View File

@ -121,7 +121,9 @@
- (instancetype)initWithFrame:(CGRect)frame shader:(id<RTCVideoViewShading>)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<RTCVideoViewShading>)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 {