Skip to content

Commit f329796

Browse files
authored
[iOS] Fix FlutterViewController retain cycle (flutter#43379)
Fixes [flutter#126560](flutter#126560)
1 parent a858e98 commit f329796

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2190,7 +2190,7 @@ @interface FlutterTextInputPlugin ()
21902190
NSMutableDictionary<NSString*, FlutterTextInputView*>* autofillContext;
21912191
@property(nonatomic, retain) FlutterTextInputView* activeView;
21922192
@property(nonatomic, retain) FlutterTextInputViewAccessibilityHider* inputHider;
2193-
@property(nonatomic, readonly) id<FlutterViewResponder> viewResponder;
2193+
@property(nonatomic, readonly, weak) id<FlutterViewResponder> viewResponder;
21942194
@end
21952195

21962196
@implementation FlutterTextInputPlugin {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,16 @@ - (void)testBinaryMessenger {
10551055
OCMVerify([self.mockEngine binaryMessenger]);
10561056
}
10571057

1058+
- (void)testViewControllerIsReleased {
1059+
__weak FlutterViewController* weakViewController;
1060+
@autoreleasepool {
1061+
FlutterViewController* viewController = [[FlutterViewController alloc] init];
1062+
weakViewController = viewController;
1063+
[viewController viewDidLoad];
1064+
}
1065+
XCTAssertNil(weakViewController);
1066+
}
1067+
10581068
#pragma mark - Platform Brightness
10591069

10601070
- (void)testItReportsLightPlatformBrightnessByDefault {

0 commit comments

Comments
 (0)