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 {