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:
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user