Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate FlutterRestorationPlugin, FlutterTextureRegistryRelay, FlutterScreenAndSceneIfLoaded to ARC #51984

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "flutter/fml/logging.h"

FLUTTER_ASSERT_NOT_ARC
FLUTTER_ASSERT_ARC

@interface FlutterRestorationPlugin ()
@property(nonatomic, copy) FlutterResult pendingRequest;
Expand Down Expand Up @@ -54,8 +54,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {

- (void)setRestorationData:(NSData*)data {
if (data != _restorationData) {
[_restorationData release];
_restorationData = [data retain];
_restorationData = data;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like it needs to be a copy based on its usage. It's strong in the header.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect NSData to use copy for the same reason as NSString and the collection types: you never know when someone might pass you the mutable version instead. The framework classes generally use CoW so that copy is ~free when not actually needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think swapping that in the header is a breaking change somehow?

@property(nonatomic, strong) NSData* restorationData;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory it could break us if we have code somewhere relying on passing in NSMutabledata and then modifying it after the fact. Hopefully that's not the case; it sounded like you had determined that it wasn't. But I can do a sweep too for safety.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only see it set in one place, and that's from method channel handler arguments, which should definitely not be something that changes after the fact. Switching to copy looks safe to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had done a sweep and it looked good to me, but for some reason when I asked just now I thought FlutterRestorationPlugin.h was in the umbrella header. That's what I get for doing this at 11:30pm and then paging it all out for a day. Thanks for double checking me 🙂

}
_waitForData = NO;
if (self.pendingRequest != nil) {
Expand Down Expand Up @@ -91,10 +90,4 @@ - (NSDictionary*)dataForFramework {
};
}

- (void)dealloc {
[_restorationData release];
[_pendingRequest release];
[super dealloc];
}

@end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header for this file is declaring parent as assign; it should be weak so that it's safe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sheesh, good eye.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "flutter/fml/logging.h"

FLUTTER_ASSERT_ARC

@implementation FlutterTextureRegistryRelay : NSObject

#pragma mark - FlutterTextureRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down