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