Skip to content

Commit

Permalink
[ios] Fix memory leak in ChildClippingView (#50389)
Browse files Browse the repository at this point in the history
This fixes the memory leak in `ChildClippingView`.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
0xZOne authored Feb 8, 2024
1 parent 45137ea commit 104804a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ TheOneWithTheBraid <[email protected]>
Twin Sun, LLC <[email protected]>
Qixing Cao <[email protected]>
LinXunFeng <[email protected]>
Amir Panahandeh <[email protected]>
Amir Panahandeh <[email protected]>
Rulong Chen(陈汝龙)<[email protected]>

Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ - (void)testChildClippingViewHitTests {
XCTAssertTrue([childClippingView pointInside:CGPointMake(199, 199) withEvent:nil]);
}

- (void)testReleasesBackdropFilterSubviewsOnChildClippingViewDealloc {
__weak NSMutableArray<UIVisualEffectView*>* weakBackdropFilterSubviews = nil;
@autoreleasepool {
ChildClippingView* clipping_view = [[ChildClippingView alloc] initWithFrame:CGRectZero];
weakBackdropFilterSubviews = clipping_view.backdropFilterSubviews;
XCTAssertNotNil(weakBackdropFilterSubviews);
clipping_view = nil;
}
XCTAssertNil(weakBackdropFilterSubviews);
}

- (void)testApplyBackdropFilter {
flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate;
auto thread_task_runner = CreateNewThread("FlutterPlatformViewsTest");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
// filters.
- (void)applyBlurBackdropFilters:(NSArray<PlatformViewFilter*>*)filters;

// For testing only.
- (NSMutableArray*)backdropFilterSubviews;
@end

namespace flutter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ - (void)dealloc {

- (NSMutableArray*)backdropFilterSubviews {
if (!_backdropFilterSubviews) {
_backdropFilterSubviews = [[[NSMutableArray alloc] init] retain];
_backdropFilterSubviews = [[NSMutableArray alloc] init];
}
return _backdropFilterSubviews;
}
Expand Down

0 comments on commit 104804a

Please sign in to comment.