(Animations :stars:*):* Ive managed to fine tune m...
# compose
z
(Animations 🌠*):* Ive managed to fine tune my app to some extreme smoothness, but I cant really seem to acheive the same smoothness when using
AnimatedContent
. Theres almost always a slight stutter when using it to transition to a new screen; and its almost always exclusive to the first time the screen is shown - from there and on the transition is smooth for as long as the app is running. Using R8, baseline profiles, etc. Is this a known issue; or am I simply doing something wrong? Ill attach a simple code example in the thread. 🧵
âž• 1
I use this for a
loading -> content
transition. TargetState is the value/screen Im looking to show, which is null for the duration of the load.
Copy code
updateTransition(
    targetState = targetState,
    label = null,
).AnimatedContent(
    contentKey = { value -> value != null },
    transitionSpec = {
        with(TransitionScope(this)) {
            if (requiresAnimation) {
                transition().invoke()
            } else {
                Empty
            }
        }
    },
    content = { available ->
                val currentContent = content

                if (available && currentContent != null) {
                    LogComposition("content")
                    Render(currentContent)
                } else {
                    LogComposition("loading")
                    Loader(Full)
                }
    },
)
Render(currentContent)
leads to 1 recomposition of the screen itself. The content block is invoked a bunch of times during the animation, but no work is really done thanks to skipping. Here are the logs for that:
Copy code
Recomposed loading #0
Recomposed loading #1
Recomposed content #0
Recomposed loading #2
Recomposed content #1
Recomposed content #2
Recomposed content #3