-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[ASLayout] Remove flattened property #3039
[ASLayout] Remove flattened property #3039
Conversation
…hat includes a layout that was reused
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.
Thanks for working on this, @maicki!
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 we should not do this, and instead fix the logic issue in this method.
- This diff will cause a lot more layout copying.
- The flattened flag actually makes perfect sense
- Right now the logic in this method is the real problem.
I'm on phone right now so I can't articulate the correct solution, but it's basically to stop skipping self and change the loop structure.
I was looking at this code recently with some of the Yoga stuff (setting flattened on the layouts created that way, since they are already flat). It's definitely key for performance, which IIRC is the main reason the flattened flag was added (maybe we should add comments internal documentation about this, since it's unusual?) The great thing about ASLayout is that it provides an incredibly powerful & useful hook for both developers' own custom layouts (calculateLayoutThatFits:, etc) and entire layout engines to be integrated. I bet we could even use it in the new "ASCollectionLayout" (or ASLayoutManager) class. Because ASLayout is the #1 most frequently created ASDK object, it's a worthwhile pursuit to make it as fast as possible. The good news is that after the perf work that @maicki did last year, ASLayout is now quite well optimized! |
@maicki and I discussed and agreed on the changes in this PR before he pushed it, so I accepted it a bit too fast. I think we're looking at 2 different flags here:
The fact that we merged these 2 flags into one After looking at this method again, I started to wondering if we need either of these flags at all! Please correct me if I'm wrong, but I think
Let me know what you all think. |
Let's revisit this in the future. The flattening process needs work but I don't think this diff is the way, and we've got bigger fish to fry. |
The
flattened
property onASLayout
is not needed anymore in the algorithm to flatten a layout:filteredNodeLayoutTree
.This should fix a bug where if a layout is reused that has the flattened property set to
YES
will be ignored in the flattening process although it should not have been.