Are there any known issues with compose on Android...
# compose
z
Are there any known issues with compose on Android 12? Ive received a few super-strange reports where ui actions have ~1 second delay; e.g. typing text in an input field has a 1 second delay between letters, etc. In all other cases, all of this happens instantaneously.
c
Are you launching any coroutines in your composable's
rememberCoroutineScope()
? That scope by default runs on
Dispatchers.Main.immediate
, so any long-running work on it would block UI rendering and event dispatching, and it should be moved to another dispatcher
z
I do use it as the overall scope so that operations stop whenever the compose-scope is cancelled, but I make sure that all background work runs on
Dispatchers.Default/IO
(and I just verified thats the case).
r
I have performance issues with
Crossfade
on Android 12, though that doesn't sound like it's related to your problem: https://issuetracker.google.com/u/1/issues/207107680
z
@Rick Regan Thank you, its hard to tell if its the same underlying issue - but your screen recordings look exactly like what Im seeing, and I do use
Crossfade
a lot. Is this local to
Crossfade
only, or does a similar thing happen with
AnimatedContent
for you as well?
r
I don't use `AnimatedContent`; in fact,
Crossfade
is the only animation I (explicitly) use.
z
@Rick Regan Got it. I just got a response about the delay being fixed after having switched to
AnimatedContent
, so thats a good sign! Thank you so much for bringing this to my attention. Im still seeing some lag on Android 12, but I think thats internal components using the broken animations, likely the same thing that
Crossfade
uses.
r
Can you share more detail on the "delay being fixed after having switched to 
AnimatedContent
?
z
Delay/Lag 🙂 Same thing that you showed in your screen-recordings.
r
Oh...I thought you meant you had a side channel with someone else 🙂
(@Doris Liu I wanted to make you aware of the issue cited above. Thank you.)
z
Oh snap, the response I was referring to is from a user of my app - I cant recreate these issues locally, so thankfully there are people out there who are happy to help :)
r
I never really looked into`AnimatedContent` so it's interesting to learn that it's a "drop-in replacement" for
Crossfade
. (Although the doc page I am looking at calls it "experimental".) I will try it out.
z
Ridiculously simplified probably, but I think of
Crossfade
like an
AnimatedContent
that just uses
fadeIn
and
fadeOut
.
r
Funny,
AnimatedContent
made the example in my issue much slower (both API 31 and 30). Although, I'm not 100% sure I'm comparing them correctly (for
Crossfade
I used 
animationSpec = tween(10)
and for 
AnimatedContent
 I used
Copy code
transitionSpec = {
  fadeIn(animationSpec = tween(5)) with
      fadeOut(animationSpec = tween(5))
},
(the low
tween
times was just to factor that out of the issue.)
z
Do you see the same behavior if you use something like a
Text
? Ive noticed that buttons do something when animating their enabled/disabled state, Im curious if something in there is related to this as well.
r
Still slow with `Text`s instead of `Button`s (both
Crossfade
and
AnimatedContent
, with
AnimatedContent
still slower).
z
Hopefully well find the answers soon enough! Have you tried running this on a real device too?
r
The
Crossfade
version I had, yes, and I saw it there too.
👍🏽 1
d
@Rick Regan Do you see any difference in performance between 30 & 31 when using
AnimatedContent
with
Copy code
slideIntoContainer(AnimatedContentScope.SlideDirection.Left) with slideOutOfContainer(AnimatedContentScope.SlideDirection.Left)
instead of fade? That might help narrow down the issue here.
r
I posted an update (with videos) to the issue (31 is much slower).
👍🏽 1