Status Update
Comments
gs...@gmail.com <gs...@gmail.com> #2
After upgrading to kotlin 2.1.0 and bumping remaining dependencies, things seem to work as expected again. EDIT: My bad; was on the wrong branch. Those upgrades did NOT help.
cl...@google.com <cl...@google.com>
an...@google.com <an...@google.com> #3
I think I managed to track it down further:
In my Child
composable, I'm actually hitting a TODO()
statement:
@Composable
fun Child(isLoading: Boolean, items: List<MyDataClass>) {
// ...
if (notYetSupported) {
TODO("This is not yet supported!")
}
// ...
}
It would seem that compose swallows this error and throws the above instead which is not very helpful.
gs...@gmail.com <gs...@gmail.com> #4
The "pending composition has not been applied" error generally means that composition continued despite something in the hierarchy previously throwing an exception. Here it looks like something is continuing a subcomposition unexpectedly, possibly a LazyList.
We should see if we can improve this error messaging. Can you send over a more complete example? The snippets here aren't fleshed out enough to reproduce this swallowing behavior.
ap...@google.com <ap...@google.com> #5
Triage notes: It feels like we're very close to having a repro case that we could run internally, but we don't know where the sub-composition is coming from.
Can you send over a more complete example?
Let's hold until we can get a stable repro case from the reporter. Could you send us a ZIP of the project that repros this issue? We'll close this out in a month if we don't get a response.
Bugjuggler: wait 1 month
ap...@google.com <ap...@google.com> #6
an...@google.com <an...@google.com> #7
This took me about an hour to extract but it reproduces the issue for me.
@file:SuppressLint("UnusedMaterialScaffoldPaddingParameter")
package com.example
import android.annotation.SuppressLint
import android.app.Application
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import kotlinx.coroutines.delay
class MyApp : Application()
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
// Scaffold is required!
Scaffold { _ ->
val a = remember { mutableStateOf(true) }
val b = remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
a.value = false
delay(50)
b.value = false
}
AnimatedVisibility(visible = a.value) { Text("Hello World") }
if (!b.value) {
TODO()
}
}
}
}
}
}
al...@mercari.com <al...@mercari.com> #8
Thank you! I was able to reproduce locally. Will look into this. We may eventually dedupe to
One thing to note is that this is definitely related to a race condition. Device speed matters, and a slower device seems more likely to trigger this exception — My aging Pixel XL from 2016 reproduces this very consistently, unlike my local emulator which doesn't demonstrate this issue at all. We had suspected that coroutines were coming into play here, so a lot of pieces are starting to come together.
an...@google.com <an...@google.com> #9
Correction: The emulator I was using had animations disabled. This seems to reproduce very consistently across devices.
It looks like our exception handling logic is try/catching Exception
instead of Throwable
. TODO() is breaking things because it throws a NotImplementedError
, which isn't caught by our error handler and doesn't cancel pending recompositions. We'll update our code to include Errors and generic Throwable classes. It's not immediately obvious if this will fix other occurrences of this exception since we don't have other reproduction cases.
Description
Version of Gradle Plugin: gradle:4.2.0-alpha09
OS: Android 9
Compose version : 1.0.0-alpha02
Kotlin compiler: 1.4.0
Problem
When I use LazyColumnFor and try to drag all the list to the end or do a fast drag between items it seems like its choppy and not smooth, if I drag till the end it will glitch on the last item
Example
@Composable
fun RecipeColumnListDemo(recipeList:List<Recipe>){
LazyColumnFor(items = recipeList) { item ->
RecipeCard(recipe = item)
}
}
where RecipeCard(recipe) loads images sincronously
@Composable
private fun RecipeCard(recipe: Recipe){
val image = imageResource(R.drawable.header)
Surface(shape = RoundedCornerShape(8.dp),elevation = 8.dp,modifier = Modifier.padding(8.dp)) {
Column(modifier = Modifier.padding(16.dp)) {
val imageModifier = Modifier.preferredHeight(150.dp).fillMaxWidth().clip(shape = RoundedCornerShape(8.dp))
Image(asset = image,modifier = imageModifier,contentScale = ContentScale.Crop)
Spacer(modifier = Modifier.preferredHeight(16.dp))
Text(text = recipe.title,style = typography.h6)
for(ingredient in recipe.ingredients){
Text(text = "* $ingredient",style = typography.body2)
}
}
}
}
I have also changed the way I load images with loadImageResource, but its also not a smooth scroll when I fast drag to the end of the list
Is this issue on my side ?
I have tried JetChat and it uses a ScrollableColumn which the scrolling is smoother than the the LazyColumnFor
Video: