Fix retain cycles in MacOS embedder (flutter/engine#24263)

This commit is contained in:
Matej Knopp
2021-02-19 19:46:34 +01:00
committed by GitHub
parent 8b602cabf2
commit a1298d0c45
4 changed files with 11 additions and 3 deletions

View File

@@ -49,7 +49,7 @@ class FlutterGLCompositor {
void SetPresentCallback(const PresentCallback& present_callback);
private:
const FlutterViewController* view_controller_;
__weak const FlutterViewController* view_controller_;
const NSOpenGLContext* open_gl_context_;
PresentCallback present_callback_;

View File

@@ -28,6 +28,10 @@ FlutterGLCompositor::FlutterGLCompositor(FlutterViewController* view_controller,
bool FlutterGLCompositor::CreateBackingStore(const FlutterBackingStoreConfig* config,
FlutterBackingStore* backing_store_out) {
if (!view_controller_) {
return false;
}
CGSize size = CGSizeMake(config->size.width, config->size.height);
if (!frame_started_) {
@@ -134,6 +138,10 @@ void FlutterGLCompositor::StartFrame() {
}
size_t FlutterGLCompositor::CreateCALayer() {
if (!view_controller_) {
return 0;
}
// FlutterGLCompositor manages the lifecycle of content layers.
// The id for a CALayer starts at 0 and increments by 1 for
// any given frame.

View File

@@ -26,7 +26,7 @@ static bool OnPresentDrawable(FlutterEngine* engine, const FlutterMetalTexture*
#pragma mark - FlutterMetalRenderer implementation
@implementation FlutterMetalRenderer {
FlutterEngine* _engine;
__weak FlutterEngine* _engine;
FlutterView* _flutterView;
}

View File

@@ -60,7 +60,7 @@ static bool OnAcquireExternalTexture(FlutterEngine* engine,
// A mapping of textureID to internal FlutterExternalTextureGL adapter.
NSMutableDictionary<NSNumber*, FlutterExternalTextureGL*>* _textures;
FlutterEngine* _flutterEngine;
__weak FlutterEngine* _flutterEngine;
}
- (instancetype)initWithFlutterEngine:(FlutterEngine*)flutterEngine {