How to reproduce:
- Create 100 ASCollectionCellNode which has 2 ASButtonNode in there
- At run time, add about 10 ASTextDisplayNode into the ASCollectionCellNode hierarchy
- For each of the button nodes, give it a text + image
- Let the ASCollection node render and start scrolling real fast. You will notice the frame rate will start dropping.
How to fix:
- Specify a preferredSize for the buttons
Notes:
I am using nodeBlockForItemAt and layouting with layoutSpecThatFit. After debug further, I think it may not only related to ASButtonNode but other problems as well. For instance, the frame rate will drop if you are creating too much ASDisplayNode at run time then append it into the ASCollectionCellNode hierarchy. I have a for loop that is creating about 12 ASTextDisplayNode then add it into ASCollectionCellNode hierarchy at run time. However, for some odd reason, if I give a preferred size to the buttons then the issue would be resolved.
It was working fine on 2.1 though.
Code:
func layoutSpecForAccessoriesNode() -> ASLayoutSpec {
// *** UNCOMMENT TO GET THIS TO WORK ***//
// button1.style.preferredSize = CGSize(width: CGFloat(32), height: CGFloat(16))
// button2.style.preferredSize = CGSize(width: CGFloat(32), height: CGFloat(16))
let stackLayoutSpec = ASStackLayoutSpec(direction: .horizontal, spacing: CGFloat(StyleDefault.regularMargin.rawValue), justifyContent: .start, alignItems: .start, children: [ button1, button2])
return ASInsetLayoutSpec(insets: UIEdgeInsets(top: -CGFloat(StyleDefault.regularMargin.rawValue) + CGFloat(StyleDefault.microMargin.rawValue), left: 0, bottom:-CGFloat(StyleDefault.smallMargin.rawValue), right: 0), child: stackLayoutSpec)
}
How to reproduce:
How to fix:
Notes:
I am using
nodeBlockForItemAtand layouting withlayoutSpecThatFit. After debug further, I think it may not only related to ASButtonNode but other problems as well. For instance, the frame rate will drop if you are creating too much ASDisplayNode at run time then append it into the ASCollectionCellNode hierarchy. I have a for loop that is creating about 12 ASTextDisplayNode then add it into ASCollectionCellNode hierarchy at run time. However, for some odd reason, if I give a preferred size to the buttons then the issue would be resolved.It was working fine on 2.1 though.
Code: