Index: webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m |
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m b/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m |
index 01c839a3bb091336c0466fae5f63742f44e82945..d39c59876407acde5d3639d37be52091cf3c1f88 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 |