-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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 FlutterView, FlutterPlatformViews, FlutterOverlayView to ARC #52535
Conversation
@@ -87,6 +92,9 @@ source_set("flutter_framework_source_arc") { | |||
"framework/Source/FlutterUndoManagerDelegate.h", | |||
"framework/Source/FlutterUndoManagerPlugin.h", | |||
"framework/Source/FlutterUndoManagerPlugin.mm", | |||
"framework/Source/FlutterView.h", | |||
"framework/Source/FlutterView.mm", | |||
"framework/Source/FlutterViewResponder.h", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FlutterViewResponder.h
wasn't included anywhere?
@@ -210,16 +210,19 @@ class FlutterPlatformViewsController { | |||
|
|||
fml::WeakPtr<flutter::FlutterPlatformViewsController> GetWeakPtr(); | |||
|
|||
void SetFlutterView(UIView* flutter_view); | |||
void SetFlutterView(UIView* flutter_view) __attribute__((cf_audited_transfer)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See cf_audited_transfer
discussion #52226 (comment)
@@ -99,6 +100,7 @@ | |||
0AC232E924BA71D300A85907 /* Source */ = { | |||
isa = PBXGroup; | |||
children = ( | |||
F76A3A892BE48F2F00A654F1 /* FlutterPlatformViewsTest.mm */, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a convenience to add it here, the test dylib made from BUILD.gn already built it.
I found this while migrating `FlutterPlatformViews_Internal.mm` to ARC #52535. I'll land this first. ```objc if (_backdropFilterView != visualEffectView) { _backdropFilterView = [visualEffectView retain]; } ``` should instead be something like: ```objc if (_backdropFilterView != visualEffectView) { id oldBackdropFilterView = _backdropFilterView; _backdropFilterView = [visualEffectView retain]; [oldBackdropFilterView release]; } ``` But that's already what the built-in MRC `nonatomic, retain` property setter does, so use that instead. Added a test that passes on this PR and fails on main.
- (void)dealloc { | ||
[_flutterAccessibilityContainer release]; | ||
[super dealloc]; | ||
return self.flutterAccessibilityContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's LGTM!
UIView* _embeddedView; | ||
} | ||
@interface FlutterTouchInterceptingView () | ||
@property(nonatomic, weak, readonly) UIView* embeddedView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not retained:
_embeddedView = embeddedView; |
@property(nonatomic) bool touchedEndedWithoutBlocking; | ||
@property(nonatomic) BOOL touchedEndedWithoutBlocking; | ||
|
||
@property(nonatomic, readonly) UIGestureRecognizer* forwardingRecognizer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swapping from scoped_nsobject
to a property.
engine/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm
Lines 1073 to 1075 in ea83156
@implementation DelayingGestureRecognizer { | |
fml::scoped_nsobject<UIGestureRecognizer> _forwardingRecognizer; | |
} |
} | ||
@interface FlutterTouchInterceptingView () | ||
@property(nonatomic, weak, readonly) UIView* embeddedView; | ||
@property(nonatomic, readonly) DelayingGestureRecognizer* delayingRecognizer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swapping from scoped_nsobject
to a property.
fml::scoped_nsobject<DelayingGestureRecognizer> _delayingRecognizer; |
@property(retain, nonatomic) NSArray<PlatformViewFilter*>* filters; | ||
@property(retain, nonatomic) NSMutableArray<UIVisualEffectView*>* backdropFilterSubviews; | ||
@property(nonatomic, copy) NSArray<PlatformViewFilter*>* filters; | ||
@property(nonatomic) NSMutableArray<UIVisualEffectView*>* backdropFilterSubviews; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutable collection, strong
|
||
// The pool contains the views that are available to use. | ||
// The number of items in the pool must not excceds `capacity`. | ||
@property(retain, nonatomic) NSMutableSet<FlutterClippingMaskView*>* pool; | ||
@property(nonatomic) NSMutableSet<FlutterClippingMaskView*>* pool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutable collection, strong
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterView () | ||
@property(nonatomic, weak) id<FlutterViewEngineDelegate> delegate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not retained
_delegate = delegate; |
@@ -417,7 +416,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, | |||
|
|||
long FlutterPlatformViewsController::FindFirstResponderPlatformViewId() { | |||
for (auto const& [id, root_view] : root_views_) { | |||
if ((UIView*)(root_view.get()).flt_hasFirstResponderInViewHierarchySubtree) { | |||
if (((UIView*)root_view.get()).flt_hasFirstResponderInViewHierarchySubtree) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error: cast of 'BOOL' (aka 'bool') to 'UIView *' is disallowed with ARC
../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm:419:9: error: cast of 'BOOL' (aka 'bool') to 'UIView *' is disallowed with ARC
419 | if ((UIView*)(root_view.get()).flt_hasFirstResponderInViewHierarchySubtree) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
This was somehow working before?
engine/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm
Lines 2771 to 2775 in ea83156
XCTAssertTrue(textField.isFirstResponder); | |
XCTAssertTrue(textField.flt_hasFirstResponderInViewHierarchySubtree); | |
[textField resignFirstResponder]; | |
XCTAssertFalse(textField.isFirstResponder); | |
XCTAssertFalse(textField.flt_hasFirstResponderInViewHierarchySubtree); |
#33093
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird
@@ -417,7 +416,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, | |||
|
|||
long FlutterPlatformViewsController::FindFirstResponderPlatformViewId() { | |||
for (auto const& [id, root_view] : root_views_) { | |||
if ((UIView*)(root_view.get()).flt_hasFirstResponderInViewHierarchySubtree) { | |||
if (((UIView*)root_view.get()).flt_hasFirstResponderInViewHierarchySubtree) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird
…148147) flutter/engine@d4f705c...ba8e0d3 2024-05-10 1961493+harryterkelsen@users.noreply.github.com [canvaskit] Clip before applying ColorFilter so it doesn't filter beyond child bounds (flutter/engine#52704) 2024-05-10 magder@google.com Migrate FlutterView, FlutterPlatformViews, FlutterOverlayView to ARC (flutter/engine#52535) 2024-05-10 matanlurey@users.noreply.github.com Infer `--rbe` based on the existence of `//flutter/build/rbe` (flutter/engine#52700) 2024-05-10 jonahwilliams@google.com [Impeller] Disable AHB swapchain. (flutter/engine#52713) 2024-05-10 skia-flutter-autoroll@skia.org Roll Skia from c7cd1e9690d1 to 11d892ce49b6 (25 revisions) (flutter/engine#52712) 2024-05-10 chinmaygarde@google.com [Impeller] Document how to do basic rendering in Impeller. (flutter/engine#52703) 2024-05-10 30870216+gaaclarke@users.noreply.github.com [impeller] adds experimental canvas docstring (flutter/engine#52710) 2024-05-10 daniel.l@hpcnt.com Roll third_party/freetype2 from 3bea27612 to af4c2d86d (2 revisions) (flutter/engine#52689) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Smart pointers support ARC as of #47612, and the unit tests were migrated in #48162.
Migrate
FlutterView
,FlutterPlatformViews
, andFlutterOverlayView
from MRC to ARC.Part of flutter/flutter#137801.