From e0fea21fbca60d593b6f224d67970353a4eb5206 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Tue, 10 Dec 2019 15:55:48 +0800 Subject: [PATCH 1/3] Fix CGMutablePathRef memory leaks --- .../ios/framework/Source/FlutterPlatformViews_Internal.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm index dc91dde315463..af8885a0f263f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm @@ -132,10 +132,10 @@ - (void)clipRRect:(const SkRRect&)clipSkRRect { } - (void)clipPath:(const SkPath&)path { - CGMutablePathRef pathRef = CGPathCreateMutable(); if (!path.isValid()) { return; } + CGMutablePathRef pathRef = CGPathCreateMutable(); if (path.isEmpty()) { CAShapeLayer* clip = [[CAShapeLayer alloc] init]; clip.path = pathRef; From f3c7f8b4d5f3bff7ebb838aab495e477ee9c263d Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 11 Dec 2019 11:49:59 +0800 Subject: [PATCH 2/3] Use CFRef instead --- .../ios/framework/Source/FlutterPlatformViews_Internal.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm index af8885a0f263f..fc5488127c51a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm @@ -5,6 +5,7 @@ #include "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" #include "flutter/shell/platform/darwin/ios/ios_surface.h" +#include "flutter/fml/platform/darwin/cf_utils.h" static int kMaxPointsInVerb = 4; @@ -135,12 +136,11 @@ - (void)clipPath:(const SkPath&)path { if (!path.isValid()) { return; } - CGMutablePathRef pathRef = CGPathCreateMutable(); + fml::CFRef pathRef(CGPathCreateMutable()); if (path.isEmpty()) { CAShapeLayer* clip = [[CAShapeLayer alloc] init]; clip.path = pathRef; self.layer.mask = clip; - CGPathRelease(pathRef); return; } @@ -198,7 +198,6 @@ - (void)clipPath:(const SkPath&)path { CAShapeLayer* clip = [[CAShapeLayer alloc] init]; clip.path = pathRef; self.layer.mask = clip; - CGPathRelease(pathRef); } - (void)setClip:(flutter::MutatorType)type From b2fbf81167b60c6519552e3fbfe01028bd844571 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 11 Dec 2019 14:00:00 +0800 Subject: [PATCH 3/3] Fix clang-format --- .../ios/framework/Source/FlutterPlatformViews_Internal.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm index fc5488127c51a..c29c7491641d1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm @@ -4,8 +4,8 @@ #include "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" -#include "flutter/shell/platform/darwin/ios/ios_surface.h" #include "flutter/fml/platform/darwin/cf_utils.h" +#include "flutter/shell/platform/darwin/ios/ios_surface.h" static int kMaxPointsInVerb = 4;