In Progress
Status Update
Comments
l....@gmail.com <l....@gmail.com> #2
Can you try with the latest snapshot? Not reproducible for me on androidx-main.
l....@gmail.com <l....@gmail.com> #3
Ok, after trying a couple more versions, realized this is a duplicate of
From the release notes:
AndroidView's update callback's first invocation will now be defered until the view is attached, instead of running when the composition that introduces the AndroidView is applied. This fixes a bug where the update callback wouldn't be invalidated if a state it read was changed immediately by an effect. (Ie9438,
) b/291094055
Sorry for the confusion!
Description
Reproduction project:https://github.com/lwasyl/compose-animations-playground/tree/ca53b643d1c0d55131b6c6623aa6c06c62a304cc
See the attached video for the observed vs expected behavior. What I believe is a bug is the fact that the green container lags behind the gray one when animating, which I attribute to the default size transform on the
AnimatedContent
composable labeledMiddleAnimationLabel
.The gray box is in
AnimatedContent
and should animate, but theAnimatedContent
around it should be a no-op — sincecontentKey = { it::class }
and the target state is always the same class. Btw you'd reproduce the same behavior withcontentKey = { "foo" }
, and the same workaround (adding anif
for the transition spec) would work too. The documentation forAnimatedContent
suggests that if the key doesn't change, there shouldn't be any animation at all.The same workaround (or just adding
using(null)
to the transition spec) can be applied toAnimatedContent
labeledOuterAnimationLabel
. Again, it has a constant key so I wouldn't expect any animation to run, regardless of the spec.Interestingly, this seems related to
NewData
class having a field with a lambda that captures some object. If you replace line 59 withlambdaWithCapture = { },
, the animations behave as expected without any other workarounds.This reproduces also in an Android project with Kotlin 2.0.0 and Compose BOM
2024.05.00
, the desktop project is just simpler to share and iterate on.