-
Notifications
You must be signed in to change notification settings - Fork 6k
iOS a11y: Implement strong down weak up reference management #4602
Conversation
|
Hmm, I do not understand the Travis failure. It seems to tell me that I should format a file that I didn't touch :/ |
|
Looks like the engine repo is red on travis for master, so that failure was probably not introduced by you: https://travis-ci.org/flutter/engine/builds/334200934 |
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.
accessibilityElementAtIndex: does not have transfer-out ownership rules of the child at that particular index. I suspect you are working around some other issue around the ownership rules. Likely by introducing a (another?) leak.
I strongly feel like we should fix the underlying issue by not holding onto these object by raw pointers. We already have smart pointers for NSObject types in FML. We also control that library and we can add more utilities to address out use case.
|
+1 to @chinmaygarde's comment. First thing to do is clarify who's responsible for object lifetime, then clean up what's there and stop relying on just the shared dict for ref-count. Everyone using an NSObject should manage their own inc/dec of the refcount. |
eecf135 to
9ba4194
Compare
|
PTAL. In this new version I made |
|
Update: I can no longer vouch for existence of a leak. It seems I have been reading the Instruments UI wrong. Many of the objects listed in it have ref count == 0. |
goderbauer
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.
LGTM
| if (top == 0.0) | ||
| return rectA.origin.x - rectB.origin.x < 0.0; | ||
| return top < 0.0; | ||
| NSComparisonResult intToComparisonResult(int32_t value) { |
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.
IntToComparisonResult for static funcs.
Fixes flutter/flutter#13701
The crash was caused by a use-after-free bug.
SemanticsObjectContaineruses a raw pointer to point to_semanticsObject. When it returns the pointer to iOS' a11y framework it does not bump the ref count. Similarly,SemanticsObjecthas a rawstd::vector<SemanticsObject*> _children, and does not bump the ref count when returning pointers to iOS. When the semantics tree is updated andAccessibilityBridge::UpdateSemanticsclears theobjects_dictionary, the ref count hits zero and the semantics objects are freed. In the mean time, iOS continues to assume that the objects are live./cc @goderbauer @chinmaygarde