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 { - (instancetype)initWithFrame:(CGRect)frame shader:(id<RTCVideoViewShading>)shader {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
_shader = shader; _shader = shader;
[self configure]; if (![self configure]) {
return nil;
}
} }
return self; return self;
} }
@ -129,17 +131,23 @@
- (instancetype)initWithCoder:(NSCoder *)aDecoder shader:(id<RTCVideoViewShading>)shader { - (instancetype)initWithCoder:(NSCoder *)aDecoder shader:(id<RTCVideoViewShading>)shader {
if (self = [super initWithCoder:aDecoder]) { if (self = [super initWithCoder:aDecoder]) {
_shader = shader; _shader = shader;
[self configure]; if (![self configure]) {
return nil;
}
} }
return self; return self;
} }
- (void)configure { - (BOOL)configure {
EAGLContext *glContext = EAGLContext *glContext =
[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
if (!glContext) { if (!glContext) {
glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
} }
if (!glContext) {
RTCLogError(@"Failed to create EAGLContext");
return NO;
}
_glContext = glContext; _glContext = glContext;
// GLKView manages a framebuffer for us. // GLKView manages a framebuffer for us.
@ -176,6 +184,7 @@
[strongSelf displayLinkTimerDidFire]; [strongSelf displayLinkTimerDidFire];
}]; }];
[self setupGL]; [self setupGL];
return YES;
} }
- (void)dealloc { - (void)dealloc {