[ios] Fix memory leak in ChildClippingView (flutter/engine#50389)

This fixes the memory leak in `ChildClippingView`.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Rulong Chen(陈汝龙)
2024-02-08 09:43:37 +08:00
committed by GitHub
parent c3d355cadd
commit e3b318920a
4 changed files with 17 additions and 2 deletions

View File

@@ -24,4 +24,6 @@ TheOneWithTheBraid <the-one@with-the-braid.cf>
Twin Sun, LLC <google-contrib@twinsunsolutions.com>
Qixing Cao <qixing.cao.83@gmail.com>
LinXunFeng <linxunfeng@yeah.net>
Amir Panahandeh <amirpanahandeh@gmail.com>
Amir Panahandeh <amirpanahandeh@gmail.com>
Rulong Chen(陈汝龙)<rulong.crl@alibaba-inc.com>

View File

@@ -246,6 +246,17 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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");

View File

@@ -120,6 +120,8 @@
// filters.
- (void)applyBlurBackdropFilters:(NSArray<PlatformViewFilter*>*)filters;
// For testing only.
- (NSMutableArray*)backdropFilterSubviews;
@end
namespace flutter {

View File

@@ -236,7 +236,7 @@ static BOOL _preparedOnce = NO;
- (NSMutableArray*)backdropFilterSubviews {
if (!_backdropFilterSubviews) {
_backdropFilterSubviews = [[[NSMutableArray alloc] init] retain];
_backdropFilterSubviews = [[NSMutableArray alloc] init];
}
return _backdropFilterSubviews;
}