Migrate FlutterRestorationPlugin, FlutterTextureRegistryRelay, FlutterScreenAndSceneIfLoaded to ARC (flutter/engine#51984)

Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/48162.

Migrate `FlutterRestorationPlugin`, `FlutterTextureRegistryRelay`, and `UIViewController+FlutterScreenAndSceneIfLoaded` from MRC to ARC.  These files do not themselves import any MRC files, making them leaf nodes in the dependency graph of MRC files.  

Doing a few at a time to make the dependency graph manageable, and to easily revert if this causes retain cycles or other memory management issues.

Part of https://github.com/flutter/flutter/issues/137801.
This commit is contained in:
Jenn Magder
2024-04-10 14:53:51 -07:00
committed by GitHub
parent 6fe9dcece5
commit 3cd96ea83c
6 changed files with 15 additions and 17 deletions

View File

@@ -61,9 +61,15 @@ source_set("flutter_framework_source_arc") {
sources = [
"framework/Source/FlutterMetalLayer.h",
"framework/Source/FlutterMetalLayer.mm",
"framework/Source/FlutterRestorationPlugin.h",
"framework/Source/FlutterRestorationPlugin.mm",
"framework/Source/FlutterTextInputDelegate.h",
"framework/Source/FlutterTextInputPlugin.h",
"framework/Source/FlutterTextInputPlugin.mm",
"framework/Source/FlutterTextureRegistryRelay.h",
"framework/Source/FlutterTextureRegistryRelay.mm",
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h",
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm",
]
frameworks = [
@@ -110,14 +116,10 @@ source_set("flutter_framework_source") {
"framework/Source/FlutterPlatformViews_Internal.h",
"framework/Source/FlutterPlatformViews_Internal.mm",
"framework/Source/FlutterPluginAppLifeCycleDelegate.mm",
"framework/Source/FlutterRestorationPlugin.h",
"framework/Source/FlutterRestorationPlugin.mm",
"framework/Source/FlutterSemanticsScrollView.h",
"framework/Source/FlutterSemanticsScrollView.mm",
"framework/Source/FlutterSpellCheckPlugin.h",
"framework/Source/FlutterSpellCheckPlugin.mm",
"framework/Source/FlutterTextureRegistryRelay.h",
"framework/Source/FlutterTextureRegistryRelay.mm",
"framework/Source/FlutterUIPressProxy.h",
"framework/Source/FlutterUIPressProxy.mm",
"framework/Source/FlutterUndoManagerDelegate.h",
@@ -131,8 +133,6 @@ source_set("flutter_framework_source") {
"framework/Source/KeyCodeMap_Internal.h",
"framework/Source/SemanticsObject.h",
"framework/Source/SemanticsObject.mm",
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h",
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm",
"framework/Source/accessibility_bridge.h",
"framework/Source/accessibility_bridge.mm",
"framework/Source/accessibility_text_entry.h",

View File

@@ -15,7 +15,7 @@
- (instancetype)initWithChannel:(FlutterMethodChannel*)channel
restorationEnabled:(BOOL)waitForData NS_DESIGNATED_INITIALIZER;
@property(nonatomic, strong) NSData* restorationData;
@property(nonatomic, copy) NSData* restorationData;
- (void)markRestorationComplete;
- (void)reset;
@end

View File

@@ -9,7 +9,7 @@
#include "flutter/fml/logging.h"
FLUTTER_ASSERT_NOT_ARC
FLUTTER_ASSERT_ARC
@interface FlutterRestorationPlugin ()
@property(nonatomic, copy) FlutterResult pendingRequest;
@@ -54,8 +54,7 @@ FLUTTER_ASSERT_NOT_ARC
- (void)setRestorationData:(NSData*)data {
if (data != _restorationData) {
[_restorationData release];
_restorationData = [data retain];
_restorationData = [data copy];
}
_waitForData = NO;
if (self.pendingRequest != nil) {
@@ -91,10 +90,4 @@ FLUTTER_ASSERT_NOT_ARC
};
}
- (void)dealloc {
[_restorationData release];
[_pendingRequest release];
[super dealloc];
}
@end

View File

@@ -22,7 +22,7 @@ FLUTTER_DARWIN_EXPORT
/**
* A weak reference to a FlutterEngine that will be passed texture registration.
*/
@property(nonatomic, assign) NSObject<FlutterTextureRegistry>* parent;
@property(nonatomic, weak) NSObject<FlutterTextureRegistry>* parent;
- (instancetype)initWithParent:(NSObject<FlutterTextureRegistry>*)parent;
@end

View File

@@ -6,6 +6,8 @@
#include "flutter/fml/logging.h"
FLUTTER_ASSERT_ARC
@implementation FlutterTextureRegistryRelay : NSObject
#pragma mark - FlutterTextureRegistry

View File

@@ -5,6 +5,9 @@
#import "flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h"
#include "flutter/fml/logging.h"
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
FLUTTER_ASSERT_ARC
@implementation UIViewController (FlutterScreenAndSceneIfLoaded)