Status Update
Comments
le...@gmail.com <le...@gmail.com> #2
Jetpack Compose release version: Both stable 1.0.1 and latest 1.2.0-alpha02
Android Studio Build: 2021.1.1 Patch 1
Kotlin version: 1.5.21
Take example from this documentation
Appending my simple example here where you can add via plus button more "blues" and see ow they dont show up after second row.
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
RedrawBugTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Screen()
}
}
}
}
}
@Composable
fun Screen() {
var blueCount by remember { mutableStateOf(1) }
Column {
Row(Modifier.height(IntrinsicSize.Min)) {
Column(Modifier.weight(1f)) { Text("Red ".repeat(10)) }
Divider(
color = Color.Black,
modifier = Modifier
.fillMaxHeight()
.width(5.dp)
)
Column(Modifier.weight(1f)) { Text("Blue ".repeat(blueCount)) }
}
Spacer(modifier = Modifier.height(100.dp))
Row {
IconButton(onClick = { ++blueCount }, content = { Icon(Icons.Default.Add, contentDescription = null) })
IconButton(onClick = { --blueCount }, content = { Icon(Icons.Default.Clear, contentDescription = null) })
}
}
}
nj...@google.com <nj...@google.com>
lp...@google.com <lp...@google.com>
so...@google.com <so...@google.com> #3
This is not a Text issue. Replacing the growing text with multiple Box
es
Column(Modifier.weight(1f)) {
repeat(blueCount) {
Box(Modifier.padding(4.dp).size(4.dp).background(Color.Magenta))
}
}
does not change the behaviour.
Over to Mihai for further investigation.
le...@gmail.com <le...@gmail.com> #4
Yes, this should be issue with any composable that is sibling to vertical divider inside intrinsic-min parent. Sorry for not being clear in report.
po...@google.com <po...@google.com>
an...@google.com <an...@google.com> #5
ma...@hopper.com <ma...@hopper.com> #6
Any updates on this?
I'm pretty sure this is the bug behind this StackOverflow question too:
The intrinsic size calculation is wrong for some reasons (probably not passing in the proper constraints when calculating the intrinsic size of the children).
A simpler demo of the issue is:
@Preview(showBackground = true, widthDp = 300, heightDp = 400)
@Composable
fun TestRowCompose() {
LazyColumn() {
item {
Row(
modifier = Modifier
.height(intrinsicSize = IntrinsicSize.Min)
.background(Color.Magenta),
verticalAlignment = Alignment.Top,
) {
Text(text = "abcde", Modifier.fillMaxWidth(0.25f).background(Color.Red))
}
}
}
}
I'm expecting the Magenta background to be the height of the Red backgorund, but instead it is bigger.
It's actually as high as the text if each characters were rendered on their own line, which seems to indicate an improper constraints in width when measuring the minIntrinsicHeight
for the Text
.
Adding characters to the text grows the vertical height of the Purple background, which is unexpected.
sz...@gmail.com <sz...@gmail.com> #7
Any updates on this?
uo...@google.com <uo...@google.com> #9
This is actually a text bug. It has to do with the cache stopping the update from happening:
I tested out the sample
Reassigning to Sean to take a look
se...@google.com <se...@google.com> #10
Thanks for digging into this!
se...@google.com <se...@google.com> #11
I suspect there may be two bugs stacked on top of each other based on history.
I'll fix the text over-caching issue quick and then we can see if the remaining intrinsics bug lingers.
Thanks!
Sean
se...@google.com <se...@google.com> #12
Update: It looks like this was just a text issue I can't reproduce without text.
Fixing in aosp/2962173
ap...@google.com <ap...@google.com> #13
Branch: androidx-main
commit e9ef4f948b25c55dd15eecf31476b287fd3966d8
Author: Sean McQuillan <seanmcq@google.com>
Date: Tue Feb 13 16:58:34 2024
Don't cache intrinsicHeight through text changes
Only applies to annotatedstring / layout result implementation
Fixes:
Test: ./gradlew :com:found:found:cAT
Change-Id: Ied047b99122e43d1a0c088f742fe090df5c0c4c2
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCacheTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/modifiers/MultiParagraphLayoutCache.kt
mt...@gmail.com <mt...@gmail.com> #14
Any hope this fix will make it into a 1.6.x release?
se...@google.com <se...@google.com> #15
Trying to get it into 1.6.2
se...@google.com <se...@google.com> #16
Yep, it's heading in to 1.6.2.
Thanks for asking! Was able to make the cut :)
se...@google.com <se...@google.com> #17
Since hotpatching and linking to this bug - adding notes.
This bug applied if any of the following conditions were met:
- Text was selectable (selection container is not null)
- Text is annotated string
- onTextLayoutResult callback is not null
The "simple text" path (which exists for optimization reasons) did not have this bug. Notably TextStringSimpleNode / Paragraph cache was already
To force the issue if it is appearing randomly in your app, the easiest way would be to ensure you always pass an AnnotatedString for all Text/BasicText that you're debugging.
pr...@google.com <pr...@google.com> #18
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.6.2
androidx.compose.foundation:foundation-android:1.6.2
androidx.compose.foundation:foundation-desktop:1.6.2
androidx.compose.foundation:foundation:1.7.0-alpha03
androidx.compose.foundation:foundation-android:1.7.0-alpha03
androidx.compose.foundation:foundation-desktop:1.7.0-alpha03
mt...@gmail.com <mt...@gmail.com> #19
Thanks for including it into 1.6.2, which allows me to fix an annoying display bug!
Description
Description has been deleted.