From 9a425c81af9e3df715464783faebcf111da7cc36 Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Tue, 2 Mar 2021 13:57:44 +0100 Subject: [PATCH] Switch to correct OpenGL context before deleting framebuffers. (flutter/engine#24679) https://github.com/flutter/flutter/issues/76920 --- .../macos/framework/Source/FlutterFrameBufferProvider.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm index b2ee64cf39f..c28d904587e 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm @@ -9,6 +9,7 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h" @interface FlutterFrameBufferProvider () { + const NSOpenGLContext* _openGLContext; uint32_t _frameBufferId; uint32_t _backingTexture; } @@ -17,7 +18,8 @@ @implementation FlutterFrameBufferProvider - (instancetype)initWithOpenGLContext:(const NSOpenGLContext*)openGLContext { if (self = [super init]) { - MacOSGLContextSwitch context_switch(openGLContext); + _openGLContext = openGLContext; + MacOSGLContextSwitch context_switch(_openGLContext); glGenFramebuffers(1, &_frameBufferId); glGenTextures(1, &_backingTexture); @@ -46,6 +48,8 @@ } - (void)dealloc { + MacOSGLContextSwitch context_switch(_openGLContext); + glDeleteFramebuffers(1, &_frameBufferId); glDeleteTextures(1, &_backingTexture); }