Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 104804a

Browse files
authored
[ios] Fix memory leak in ChildClippingView (#50389)
This fixes the memory leak in `ChildClippingView`. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 45137ea commit 104804a

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

AUTHORS

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ TheOneWithTheBraid <[email protected]>
2424
Twin Sun, LLC <[email protected]>
2525
Qixing Cao <[email protected]>
2626
LinXunFeng <[email protected]>
27-
Amir Panahandeh <[email protected]>
27+
Amir Panahandeh <[email protected]>
28+
Rulong Chen(陈汝龙)<[email protected]>
29+

shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm

+11
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ - (void)testChildClippingViewHitTests {
246246
XCTAssertTrue([childClippingView pointInside:CGPointMake(199, 199) withEvent:nil]);
247247
}
248248

249+
- (void)testReleasesBackdropFilterSubviewsOnChildClippingViewDealloc {
250+
__weak NSMutableArray<UIVisualEffectView*>* weakBackdropFilterSubviews = nil;
251+
@autoreleasepool {
252+
ChildClippingView* clipping_view = [[ChildClippingView alloc] initWithFrame:CGRectZero];
253+
weakBackdropFilterSubviews = clipping_view.backdropFilterSubviews;
254+
XCTAssertNotNil(weakBackdropFilterSubviews);
255+
clipping_view = nil;
256+
}
257+
XCTAssertNil(weakBackdropFilterSubviews);
258+
}
259+
249260
- (void)testApplyBackdropFilter {
250261
flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate;
251262
auto thread_task_runner = CreateNewThread("FlutterPlatformViewsTest");

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
// filters.
121121
- (void)applyBlurBackdropFilters:(NSArray<PlatformViewFilter*>*)filters;
122122

123+
// For testing only.
124+
- (NSMutableArray*)backdropFilterSubviews;
123125
@end
124126

125127
namespace flutter {

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ - (void)dealloc {
236236

237237
- (NSMutableArray*)backdropFilterSubviews {
238238
if (!_backdropFilterSubviews) {
239-
_backdropFilterSubviews = [[[NSMutableArray alloc] init] retain];
239+
_backdropFilterSubviews = [[NSMutableArray alloc] init];
240240
}
241241
return _backdropFilterSubviews;
242242
}

0 commit comments

Comments
 (0)