raamcosta / compose-destinations

Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
https://composedestinations.rafaelcosta.xyz
Apache License 2.0
3.23k stars 134 forks source link

navigation animation is laggy #699

Open proxiti opened 3 weeks ago

proxiti commented 3 weeks ago

version: 1.11.7 navigation-compose version: 2.8.3 Navigation animation is laggy when ui changes.

Here is a simple demo, when navigating to Detail from any destination, skip frames occur when updating the text.

Navigation animation is:

enterTransition = {
    slideIntoContainer(
        AnimatedContentTransitionScope.SlideDirection.Left,
        tween(400)
    )
}

ViewModel:

class DetailViewModel : ViewModel() {
    val textState = MutableStateFlow("test")

    init {
        viewModelScope.launch {
            delay(300)
            textState.value = "this is a performance test" // skip frames when updating text
        }
    }
}

UI:

private fun Detail() {
    val vm: DetailViewModel = viewModel()
    val text by vm.textState.collectAsState()
    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.Gray),
    ) {
        for (i in 1..100)
            Text(text = text)
    }
}