Status Update
Comments
to...@gmail.com <to...@gmail.com> #2
After doing a lot of tests this seems to be tied to ImageVector.
After removing nearly everything in a deep hierarchy I just left
Crossfade(targetState = isPlaying, label = "") { isPlaying ->
Icon(
painter = rememberImageErrorPainter(SymfoniumIcons.Rounded.MusicNote, true),
contentDescription = "Toggle play/pause",
modifier = Modifier
.size(48.dp)
.padding(4.dp)
.align(Alignment.Center)
.clip(CircleShape)
.combinedClickable(onClick = { viewModel.playPause() }, onLongClick = { viewModel.stop() })
.padding(all = 6.dp),
tint = buttonColor,
)
}
with
@Composable
fun rememberImageErrorPainter(
imageVector: ImageVector,
showIcon: Boolean,
backgroundColor: Color = materialPlaceHolderColor(),
scale: Float = SurfaceImageErrorDefaults.scale,
alpha: Float = SurfaceImageErrorDefaults.alpha,
color: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = alpha),
): Painter = rememberErrorPainter(
if (showIcon) rememberVectorPainter(image = imageVector) else null,
backgroundColor,
color,
scale,
)
This will trigger the infinite refresh, if I change and pass false to rememberImageErrorPainter
so no more using a VectorPainter then the issue stops.
This also happen with a simple Icon(Icons.Default.Stop)
for example.
an...@google.com <an...@google.com>
to...@gmail.com <to...@gmail.com> #3
So built a very small repro
Clone, run (tested on Pixel 6 pro), Start Profile HWUI rendering, see that the app does not refresh the screen. Press toggle. See that the screen keeps refreshing for ever and very fast. Return to home, return to the app see that the issue is no more present. Press toggle again and the issue is back.
There's probably a lot of other ways to reproduce this.
Would love to have this acknowledged and P1 if there's no possible workaround on app side.
to...@gmail.com <to...@gmail.com> #4
As added note to speed up debug.
Doing the rememberVectorPainter
just outside of the AnimatedVisibility
does fix the issue.
But obviously when using Icon(imageVector = Icons.Default.AccountBox)
for example we do not have control over the rememberVectorPainter
ti...@google.com <ti...@google.com> #5
Re
If the issue is reproducible with Crossfade
as you mentioned in Crossfade
doesn't use lookahead at all.
Just to double check: Is this a recent regression? Is the same issue reproducible on compose 1.6 A1 and 1.5?
to...@gmail.com <to...@gmail.com> #6
It is a recent regression, I regularly check HWUI profiler and did not see it before.
Unfortunately reverting to before 1.6 A2 is a pain as I've migrated to all the mutableXXstateof and a few other changes.
I'm not sure of all the possible repro but #3 have a 100% working one.
I've just checked on another prod app I have on my phone that is using compose alphas and it behave exactly the same. So not related to something specific in my code. (The #3 repro have nothing specific too as I think as many can use that pattern).
The battery usage / and perf impact is huge. Even if it's fixed I'd love to know a way to automatically detect this as I completely miss this in my last prod release.
It is possible that my #3 test still had some AnimatedVisibility somewhere that triggered that. I have no idea how to debug and detect what is recomposing and why.
ti...@google.com <ti...@google.com> #7
I was able to reproduce this locally with the project in
It seems like the vector gets repeatedly and indefintely invalidated for some reason, even after animations have finished. More specifically, the onDraw
in VectorPainter
gets repeatedly invoked:
Based on my logging, there's no size change or composition in the node emitted by Image
while the infinite redrawing of the vector is going on. Unclear what's triggering the invalidation.
Nader, could you take a look at this please?
to...@gmail.com <to...@gmail.com> #8
For my information is there a way for me to debug this on Windows since there's still no support for building Androidx for me ?
Systrace did not contain that call in main thread for vectordrawable and I found the cause by luck.
ey...@gmail.com <ey...@gmail.com> #9
I'm having the same issue with:
Icon(
imageVector = Icons.Filled.CheckCircle,
contentDescription = null,
modifier = Modifier.requiredSize(16.dp)
)
in a ListItem's
supportingContent
in a LazyColumn
. If I convert the LazyColumn
to a vertically scrollable Column
then the issue goes away.
As I scroll the list, it is very janky (even in release) and the icons randomly disappear after scrolling (scrolling them off screen and back sometimes makes the icon come back, but others disappear).
I can't get the layout inspector to work. I can get a screen recording if needed.
I'm using 1.6.0-alpha04 and material3 1.2.0-alpha06
nj...@google.com <nj...@google.com> #10
This should be addressed with the fix for
br...@gmail.com <br...@gmail.com> #11
the issue seems to be fixed on 1.6.0-alpha06, however, the same thing happen if I have an AnimatedContent, it does not happen if I use Crossfade....
just adding an empty AnimatedContent causes the infinite render loop, I'm trying to create a replicable code
ey...@gmail.com <ey...@gmail.com> #12
Is 1.6.0-alpha06 released yet?
[Deleted User] <[Deleted User]> #13
I believe that I'm facing the same issue. I have a BottomNavigationBar
that is very regularly flickering (video attached). Each BottomNavigationItem
has an Icon
, like so:
Icon(
painterResource(tab.iconResId(isTabSelected)),
contentDescription = tab.contentDescription,
modifier = Modifier.size(28.dp),
)
This repros with androidx.compose.foundation
1.6.0.alpha01 through 1.6.0.alpha05. I'm unable to downgrade to 1.5* due to many 1.6+ API usages.
I don't see this so claimed 1.6.0-alpha06
update. It doesn't seem released yet:
Is there are recommended workout for this in the mean time?
[Deleted User] <[Deleted User]> #14
For folks looking for a workaround, I've had success completely circumventing the VectorPainter:
@Composable
private fun rememberIconBitmapImage(
@DrawableRes vectorResId: Int,
iconSize: Dp,
): ImageBitmap? {
val size = with(LocalDensity.current) { iconSize.roundToPx() }
val context = LocalContext.current
val iconBitmap = remember(vectorResId, iconSize) {
AppCompatResources.getDrawable(context, vectorResId)?.toBitmap(height = size, width = size)
?.asImageBitmap()
}
return iconBitmap
}
Then, using the ImageBitmap
in an Image
composable:
Image(
bitmap = imageBitmap,
contentDescription = "description",
colorFilter = ColorFilter.tint(iconTint),
)
to...@gmail.com <to...@gmail.com> #15
PSA: The fix was just reverted in main so in next compose release...
to...@gmail.com <to...@gmail.com> #16
Can this be reopened ? As said the fix was reverted, the bug is back and 1.7 is now branched. This will lead to a bugged 1.6 release in current form if this is not merged back enough to be backported.
nj...@google.com <nj...@google.com> #17
Hey folks, we're actively investigating this issue. While it was reopened recently it was still being worked on internally. Thanks for following up!
to...@gmail.com <to...@gmail.com> #18
Can priority be changed to ensure backport since 1.7 is branched.
nj...@google.com <nj...@google.com> #19
The priority of the issue does not necessarily influence the decision to cherry-pick to other releases. We will chat with some folks in the meantime to discuss options. Thanks!
ek...@uber.com <ek...@uber.com> #20
Any news if this will make it into a 1.6 release? This would block our upgrade.
ey...@gmail.com <ey...@gmail.com> #21
I'm using 1.6.0-beta01 and seeing a lot of skipped frames getting logged. Would this issue cause that, or could it be something else going on?
to...@gmail.com <to...@gmail.com> #22
Check HWUI PROFILER if there's full FPS refresh it's probably that. Else check composition counts via AS.
to...@gmail.com <to...@gmail.com> #23
Can we have some news about this one? This is a critical one, currently stuck in an old 1.6 alpha with mem leaks, those mem leaks are less blocking than this, yet I can't revert to 1.5 as 1.6 have tons of vital fixes to touches / velocity handling on a few devices.
xu...@gmail.com <xu...@gmail.com> #24
Are there any updates? It exists in 1.6.0-alpha08 - 1.6.0-beta03.
nj...@google.com <nj...@google.com> #25
There is a fix that landed recently that reduces the amount of frames generated when vector graphics are leveraged.
nj...@google.com <nj...@google.com> #26
lo...@gmail.com <lo...@gmail.com> #27
Can you link the CL/diff?
nj...@google.com <nj...@google.com>
01...@gmail.com <01...@gmail.com> #29
I would like to know in which version this bug was fixed
nj...@google.com <nj...@google.com> #30
The fix was cherry-picked into the 1.6 release
Description
Jetpack Compose component used: Many
Android Studio Build: Hedgehog C16
Kotlin version: 1.9.10
Just discovered a new issue that I can't really debug.
In my app it seems some Compose internals keeps running and refreshing the view for no reasons.
When I start some animations then stop them (and even remove them completely from composition) the screen keeps refreshing. (See attached video of HWUI profiling).
I've triple checked there's nothing running in my app that can cause that, the layout inspector shows 0 recomposition and a systrace shows nothing in my code called (Attached). Just recomposition and animation.
Just pressing home then returning to the app fix this. So seems something resets and it tied to lifecycle?
Any idea how I can debug this if it's tied to my code?