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
Refactor Semantics in preparation for ARC migration #52729
Conversation
aa3da13
to
0700783
Compare
@@ -231,7 +231,7 @@ constexpr float kScrollExtentMaxForInf = 1000; | |||
bridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | |||
NS_DESIGNATED_INITIALIZER; | |||
|
|||
@property(nonatomic, weak) SemanticsObject* semanticsObject; | |||
@property(nonatomic, assign) SemanticsObject* semanticsObject; |
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.
Made this assign
to get the property synthesis. I'm going to change it back to weak
when I do the ARC migration, which allows weak property synthesis. This header isn't public.
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.
oh wow i didn't know they have weak
support in MRC.
Made this assign to get the property synthesis
Soweak
in MRC doesn't synthesize the getter/setter/ivar?
/** Should only be called in conjunction with setting child/parent relationship. */ | ||
- (void)privateSetParent:(SemanticsObject*)parent; | ||
@property(nonatomic, assign, readwrite) SemanticsObject* parent; |
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.
Swap privateSetParent:
to a readwrite
property.
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.
nit: readwrite
is already the default
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.
this will change to weak in arc right?
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.
Yes, I will make it weak in the ARC migration PR.
I was making the readwrite
explicit since it's now overriding a readonly
in the header:
@property(nonatomic, assign, readonly) SemanticsObject* parent;
} | ||
|
||
@end | ||
|
||
@implementation SemanticsObjectContainer { | ||
SemanticsObject* _semanticsObject; |
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.
This backing ivar isn't when I swap from weak
to assign
. I included it here because when I migrate to ARC this isn't needed since the weak
ARC property is auto-synthesized.
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 love to see all this modernization! LGTM!
Just some extremely optional comments.
[_children release]; | ||
[_childrenInHitTestOrder release]; | ||
|
||
_parent = nil; | ||
_container.get().semanticsObject = nil; |
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 to make sure I'm reading the other code correctly: this is safe to remove because semantics
object was changed to weak
at some point, right, and thus we don't need to explicitly clear it any 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.
That's how I read it too, I don't think weak property would need to be set to nil in MRC?
I see this comment where it was introduced:
https://github.com/flutter/engine/pull/7244/files#r259211775
But I don't see why it would be needed...
} | ||
[_children removeAllObjects]; | ||
[_childrenInHitTestOrder removeAllObjects]; | ||
[_children release]; | ||
[_childrenInHitTestOrder release]; | ||
|
||
_parent = nil; |
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.
Is this here for the same reason as the awful _inDealloc
workaround? In theory it shouldn't be necessary.
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.
The _inDealloc
workaround was done in #27786, which didn't include setting _parent
to nil.
Setting _parent
to nil was done in #4602 and I think it was for this guard:
engine/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
Lines 709 to 714 in b4b798d
if ([self parent] == nil) { | |
// This can happen when we have released the accessibility tree but iOS is | |
// still holding onto our objects. iOS can take some time before it | |
// realizes that the tree has changed. | |
return nil; | |
} |
I don't like this but it seems like iOS is, or at least was, digging around the accessibilityContainer
type methods during -[super dealloc]
which was causing crashes. I'd rather not touch that for this refactor.
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)dealloc { | ||
for (SemanticsObject* child in _children) { | ||
[child privateSetParent:nil]; | ||
child.parent = nil; | ||
} | ||
[_children removeAllObjects]; |
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.
Can we remove this too? Hopefully we don't have code that is relying on the contents of an array that came from a since-deallocated object changing out from under it...
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'll remove it in the ARC migration.
@@ -231,7 +231,7 @@ constexpr float kScrollExtentMaxForInf = 1000; | |||
bridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | |||
NS_DESIGNATED_INITIALIZER; | |||
|
|||
@property(nonatomic, weak) SemanticsObject* semanticsObject; | |||
@property(nonatomic, assign) SemanticsObject* semanticsObject; |
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.
oh wow i didn't know they have weak
support in MRC.
Made this assign to get the property synthesis
Soweak
in MRC doesn't synthesize the getter/setter/ivar?
/** Should only be called in conjunction with setting child/parent relationship. */ | ||
- (void)privateSetParent:(SemanticsObject*)parent; | ||
@property(nonatomic, assign, readwrite) SemanticsObject* parent; |
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.
nit: readwrite
is already the default
/** Should only be called in conjunction with setting child/parent relationship. */ | ||
- (void)privateSetParent:(SemanticsObject*)parent; | ||
@property(nonatomic, assign, readwrite) SemanticsObject* parent; |
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.
this will change to weak in arc right?
a134df0
to
4927970
Compare
…148338) flutter/engine@7bf8657...08b44d9 2024-05-14 [email protected] [Impeller] migrated one test over from aiks to dl (flutter/engine#52786) 2024-05-14 [email protected] [Impeller] Create framebuffer blend vertices based on the snapshot's texture size instead of coverage (flutter/engine#52790) 2024-05-14 [email protected] Refactor Semantics in preparation for ARC migration (flutter/engine#52729) 2024-05-14 [email protected] Rolls in buildroot with stack protection flag (flutter/engine#52774) 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 [email protected],[email protected],[email protected] 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
On top of the `SemanticsObject` refactor #52729 migrate `SemanticsObject` and `FlutterSemanticsScrollView` to ARC. Part of flutter/flutter#137801.
Split the too-large
Semantics
MRC to ARC migration into two PRs: this one, which refactors, and the next which will actually do the migration.copy
overstrong
.privateSetParent:
to instead use areadwrite
property inSemanticsObject ()
.semanticsObject
property fromweak
toretain
to get the synthesized property (keeping it asweak
is a compilation error in MRC) but I'll swap it back to aweak
in the ARC migration PR coming next.SemanticsObjectTest
fails on my machine and passes on CI. Switched the cleanerCGRectEqualToRect
(and related) checks to instead assert x, y, width, height so we can see the value when it fails:becomes:
Use
XCTAssertEqualWithAccuracy
now that I can see it's a floating point precision issue.