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

ListItem - trailingAccessoryContent with Button causes jank #489

Open
caltseng opened this issue Aug 25, 2023 · 1 comment
Open

ListItem - trailingAccessoryContent with Button causes jank #489

caltseng opened this issue Aug 25, 2023 · 1 comment
Assignees

Comments

@caltseng
Copy link

caltseng commented Aug 25, 2023

We've been seeing jank in our list of items (with hundreds of items), and tracked it down to the trailingAccessoryContent. Removing trailingAccessoryContent makes the list scroll very fast. Our trailingAccessoryContent is also a single Fluent button, so it's really nothing super intense, and I was also able to repro with a vanilla Material button with not much in it. Interestingly, using a text view of a constant string ("hi") is also very fast.

From the Profile Trace via AS, it says the "measureAndLayout()" step is taking a long time, which is what also led me down this investigation path.

< Fluent Version 1.30.0 >

Behavior

  • Case 1 - TrailingAccessoryContent with Fluent Button - Jank
    • trailingAccessoryContent = { Button(onClick = { }, text = "hi") { }}
  • Case 2 - TrailingAccessoryContent with material Button - Jank
    • trailingAccessoryContent = { androidx.compose.material3.Button(onClick = { /*TODO*/ }) { }}
  • Case 3 - TrailingAccessoryContent with Text("hi") - No Jank
    • trailingAccessoryContent = { Text("hi")}
  • Case 4 - No TrailingAccessoryContent - No Jank

Relevant code / code in question - ListItem, line 411

            if (trailingAccessoryContent != null && textAlignment == ListItemTextAlignment.Regular) {
                Box(
                    Modifier
                        .padding(
                            top = if (trailingAccessoryContentAlignment == Alignment.Top) padding.calculateTopPadding() else 0.dp,
                            bottom = if (trailingAccessoryContentAlignment == Alignment.Bottom) padding.calculateBottomPadding() else 0.dp,
                            end = padding.calculateEndPadding(LocalLayoutDirection.current)
                        )
                        .fillMaxHeight(),
                    contentAlignment = trailingAccessoryAlignment
                ) {
                    trailingAccessoryContent()
                }
            }

image

@Dhruv-Mishra
Copy link
Contributor

@caltseng I can confirm that the jank is present in the latest verison of fluent for list item with a trailing accessory item. Interestingly, it even persists when I use a text element with a colored box around it, but does not persist when using only a Text element. The jank is also present when a leading accessory item is used.
I also investigated the logic for alignment of the trailing item, as you suggested, and making changes to it does not help eliminate the jank either. Going to investigate this further. Please let me know if you have had any new insights about the same.

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

No branches or pull requests

3 participants