- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.2k
Ascii art visual debugging for ASLayoutSpecs #751
Conversation
| This is gold 👍 👍 👍 | 
| omg. 👍 | 
| 😍WOW 😍 | 
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 understand — this only prints out one box with the node's name in it? Or does it somehow print the hierarchy?
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 should just print the node's name. If someone wanted to make ascii art of the node hierarchy they'd pass in self.subnodes as the children.
| This is just so cool. Thanks @rcancro for one of the most delightful patches ASDK has ever seen :). If someone wants to write a few tests for this, it will keep our code coverage number up. It should be easy to add one or two in an existing test suite, just printing the node tree or spec tree of some existing hierarchy in the tests. | 
Ascii art visual debugging for ASLayoutSpecs
…rs preload state (facebookarchive#751) - After facebookarchive#706, a layout pass is forced on an ASM-enabled node that enters preload state to make sure that its subnodes can start preloading as well. However, when the node is visible, a (coalesced, thus more efficient) layout pass will be triggered by CA soon anyways, so rely on it instead.
…nters preload state (facebookarchive#779) This reverts commit 2e98588 (facebookarchive#751). The reason we can't wait for the coming CA's layout pass is that cell node visibility events occur before the pass, at which time the cell's subnodes don't have correct frames for impression tracking. The root cause of this problem is that, right now, cell node visible states are set by ASRangeController well before the layout pass of the hosting collection/table view. That means we're "jumping the gun". The more I think about this, the more I agree with @Adlai-Holler that we need to treat visible state differently. That is, a node should only be visible (and thus get visibility events) after it's fully loaded, it's view/layer attached to the hierarchy and laid out by a CA transaction. In other words, at the end of the CA layout pass. Such change needs time and effort to be thoroughly reviewed and tested. Until then, let's roll with this fix.

Created a class called
ASAsciiArtBoxCreatorthat, given a parent name and an array of string representations of the children, will create an ascii representation of the parent.Objects that want to be rendered in ascii art should implement the
ASLayoutableAsciiArtProtocolprotocol. The two methods are:I have updated
ASDisplayNodeandASLayoutSpecso that they conform to this new protocol. If you are working on a layout, you can put a breakpoint at the end of- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSizeand typepo [layoutSpec asciiArtString]to see a visual representation of your layout.For example, this is what the layout for
KittenNodelooks like:Here is an example of a more complicated example: