-
Notifications
You must be signed in to change notification settings - Fork 6k
Refactor Semantics in preparation for ARC migration #52729
Conversation
aa3da13 to
0700783
Compare
| 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
Soweakin 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.
stuartmorgan-g
left a comment
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.
| [_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 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.
| [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.
| 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
Soweakin 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
SemanticsMRC to ARC migration into two PRs: this one, which refactors, and the next which will actually do the migration.copyoverstrong.privateSetParent:to instead use areadwriteproperty inSemanticsObject ().semanticsObjectproperty fromweaktoretainto get the synthesized property (keeping it asweakis a compilation error in MRC) but I'll swap it back to aweakin the ARC migration PR coming next.SemanticsObjectTestfails 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
XCTAssertEqualWithAccuracynow that I can see it's a floating point precision issue.