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 I scroll fast in the LazyVerticalStaggeredGrid it gets stuck, I've tried release and R8 Proguard #1927

Closed
phcbest opened this issue Nov 25, 2023 · 2 comments

Comments

@phcbest
Copy link

phcbest commented Nov 25, 2023

To Reproduce
There are about two hundred pictures in the LazyVerticalStaggeredGrid, which will cause lag when sliding quickly.
its my code

@Composable
private fun ImageSelect(mediaList: List<MediaSelectBean>) {
    LazyVerticalStaggeredGrid(columns = StaggeredGridCells.Fixed(3), modifier = Modifier.padding(horizontal = 6.dp)) {
        mediaList.forEachIndexed { index, mediaSelectBean ->
            item(key = index) {
                MediaItem(mediaSelectBean)
            }
        }
    }
}

@Preview
@Composable
private fun MediaItem(mediaSelectBean: MediaSelectBean? = null) {
    val aspectRatio = (mediaSelectBean?.width ?: 1).coerceAtLeast(1) / (mediaSelectBean?.height ?: 1).coerceAtLeast(1).toFloat()
    Surface(
        color = Color.LightGray, modifier = Modifier
            .fillMaxWidth()
            .aspectRatio(aspectRatio)
            .padding(8.dp),
        shape = RoundedCornerShape(6.dp)
    ) {
        AsyncImage(
            model = ImageRequest.Builder(LocalContext.current)
                .data(mediaSelectBean?.mediaPath)
                .crossfade(true)
                .build(), contentDescription = null,
            contentScale = ContentScale.Crop,
            modifier = Modifier.fillMaxSize()
        )
    }
}

Logs/Screenshots
https://github.com/coil-kt/coil/assets/44636532/03eba39b-c0bc-443f-a401-73ed6f3124d5

Version
coilComposeVersion = "2.5.0" ,Mobile phone model Xiaomi 5s, Android version 11

@phcbest phcbest changed the title When I scroll fast in the LazyVerticalStaggeredGrid it gets stuck, I've tried release and R8 got confused When I scroll fast in the LazyVerticalStaggeredGrid it gets stuck, I've tried release and R8 Proguard Nov 25, 2023
@colinrtwhite
Copy link
Member

By "it gets stuck" do you mean it drops frames? Can you try reducing this setting to 3 or 2 and see if that helps?

@colinrtwhite
Copy link
Member

Going to close this out and track Compose perf issues under this issue: #1866

@colinrtwhite colinrtwhite closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
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