From 41a32874727160d3309ba5b1783a4c87a7fd9d64 Mon Sep 17 00:00:00 2001 From: tkchin Date: Wed, 17 Aug 2016 16:02:58 -0700 Subject: [PATCH] Nil out EAGLContext explicitly on RTCEAGLVideoView dealloc. Theoretical fix to address some EAGLContext issues from other UIImageViews that could be active. NOTRY=True BUG= Review-Url: https://codereview.webrtc.org/2259513002 Cr-Commit-Position: refs/heads/master@{#13806} --- webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m b/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m index 01c839a3bb..d39c598764 100644 --- a/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m +++ b/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m @@ -93,6 +93,7 @@ @implementation RTCEAGLVideoView { RTCDisplayLinkTimer *_timer; + EAGLContext *_glContext; // This flag should only be set and read on the main thread (e.g. by // setNeedsDisplay) BOOL _isDirty; @@ -123,11 +124,12 @@ if (!glContext) { glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; } - _glRenderer = [[RTCOpenGLVideoRenderer alloc] initWithContext:glContext]; + _glContext = glContext; + _glRenderer = [[RTCOpenGLVideoRenderer alloc] initWithContext:_glContext]; // GLKView manages a framebuffer for us. _glkView = [[GLKView alloc] initWithFrame:CGRectZero - context:glContext]; + context:_glContext]; _glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888; _glkView.drawableDepthFormat = GLKViewDrawableDepthFormatNone; _glkView.drawableStencilFormat = GLKViewDrawableStencilFormatNone; @@ -169,6 +171,9 @@ [self teardownGL]; } [_timer invalidate]; + if (_glContext && [EAGLContext currentContext] == _glContext) { + [EAGLContext setCurrentContext:nil]; + } } #pragma mark - UIView