Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASButtonNode and ASCollectionNode Performance #72

Open
QuynhNguyen opened this issue Apr 26, 2017 · 4 comments
Open

ASButtonNode and ASCollectionNode Performance #72

QuynhNguyen opened this issue Apr 26, 2017 · 4 comments

Comments

@QuynhNguyen
Copy link

QuynhNguyen commented Apr 26, 2017

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)
    }
@nguyenhuy
Copy link
Member

@QuynhNguyen This is quite unusual. Can you share a time profile or a sample project that we can check? Also, which version of Texture are you using?

@QuynhNguyen
Copy link
Author

@nguyenhuy Will do. I am using the latest release which is 2.3 I believe. Will try to put together a sample project shortly.

@QuynhNguyen
Copy link
Author

Sample.zip

carthage update --platform ios

Try to scroll real fast down the bottom of the page. After that, uncomment the code I have and try again.

@appleguy
Copy link
Member

@QuynhNguyen thanks for the great report! Indeed this is unusual, hopefully a member of the team has time to investigate in the next few days. Please do update this task if you take a time profile and notice what the difference in CPU time is from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants