Fix retain cycles in MacOS embedder (flutter/engine#24263)
This commit is contained in:
@@ -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_;
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -26,7 +26,7 @@ static bool OnPresentDrawable(FlutterEngine* engine, const FlutterMetalTexture*
|
||||
#pragma mark - FlutterMetalRenderer implementation
|
||||
|
||||
@implementation FlutterMetalRenderer {
|
||||
FlutterEngine* _engine;
|
||||
__weak FlutterEngine* _engine;
|
||||
|
||||
FlutterView* _flutterView;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user