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

When many images are loaded from the remote URL and displayed to LazyColumnForIndexed, there will be a stutter problem when sliding. #171

Closed
Merpyzf opened this issue Dec 22, 2020 · 1 comment

Comments

@Merpyzf
Copy link

Merpyzf commented Dec 22, 2020

When many images are loaded from the remote URL and displayed to LazyColumnForIndexed, there will be a stutter problem when sliding. A remote image loading component that I simply implemented by myself also has similar problems, but my implementation is implemented through onCommit().

running result:

my code:

@Composable
fun App(){
    Surface(color = MaterialTheme.colors.background) {
        LazyGridFor(items = getImages(), rowSize = 4) {
            CoilImage(data = it)
        }
    }
}

@Composable
fun <T> LazyGridFor(
    items: List<T>,
    rowSize: Int = 1,
    itemContent: @Composable BoxScope.(T) -> Unit
) {
    val rows = items.chunked(rowSize)
    LazyColumnForIndexed(rows) { index, row ->
        Row(Modifier.fillParentMaxWidth(1f)) {
            for ((index, item) in row.withIndex()) {
                Box(Modifier.fillMaxWidth(1f / (rowSize - index))) {
                    itemContent(item)
                }
            }
        }
    }
}

Thank you for your contribution!👍

@chrisbanes
Copy link
Contributor

chrisbanes commented Dec 22, 2020

This isn't a big tracker for Compose 😀.

Compose is in alpha so performance isn't expected to be perfect. If you find performance issues, please raise them on the Android bug tracker: https://issuetracker.google.com

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

2 participants