Status Update
Comments
ae...@google.com <ae...@google.com>
ka...@sz.de <ka...@sz.de> #2
ha...@google.com <ha...@google.com>
gr...@google.com <gr...@google.com> #3
lo...@gmail.com <lo...@gmail.com> #4
In the past I had the issue that it crashed when the XML layout collapsed (resulting in a height of 0) while text was selected in the composable. Maybe there is a regression regarding this edge case on some devices?
gr...@google.com <gr...@google.com> #5
does any one know how to get rid of this?
eb...@gmail.com <eb...@gmail.com> #6
gr...@google.com <gr...@google.com> #7
gr...@google.com <gr...@google.com> #8
eb...@gmail.com <eb...@gmail.com> #9
lo...@gmail.com <lo...@gmail.com> #10
In Firefox, Safari and Mobile Safari the map show up flawlessly.
In Chrome (for Mac) the position of the tiles are off by 2 pixels. I have made the background green to show the issue more prominently. The top and left styles are calculated incorrectly.
This is not an issue with browser zoom.
gr...@google.com <gr...@google.com> #11
gr...@google.com <gr...@google.com> #12
gr...@google.com <gr...@google.com> #13
ka...@sz.de <ka...@sz.de> #14
se...@gmail.com <se...@gmail.com> #15
ka...@sz.de <ka...@sz.de> #16
It doesn't only occur on Samsung devices. See the attached screenshot.
gr...@google.com <gr...@google.com> #17
Thanks for the additional info folks.
For the person with 1/10 attempts end in a crash, can you provide a sample to reproduce this?
se...@gmail.com <se...@gmail.com> #18
sure, here is a recording showing taps while trying to select some text, ending with a crash. Code sample:
LazyColumn(
contentPadding = PaddingValues(top = 4.dp, bottom = 40.dp),
state = lazyListState
) {
items(items = allWords) { word ->
Column(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
SelectionContainer {
Column(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth()
.padding(horizontal = 4.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
text = "${word.original.orEmpty()}:",
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.size(4.dp))
Text(
text = word.translation.orEmpty(),
textAlign = TextAlign.Center,
color = Color.Green
)
Spacer(modifier = Modifier.size(4.dp))
Divider()
}
}
}
}
}
video from Samsung Galaxy S20
gr...@google.com <gr...@google.com> #19
Can you share what compose versions you are using and what Android version?
gr...@google.com <gr...@google.com> #20
For my own reference, code translated to foundation only:
Edit: Adding borders around text/selection container.
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
data class Word(val original: String, val translation: String)
val word = Word("Original", "Translation")
val words = List(40) { word }
@Composable
fun SelectLayoutCrashRepro() {
Row(Modifier.fillMaxSize()) {
Box(Modifier.weight(1f)) {
SelectLayoutCrashReproColumn()
}
Spacer(modifier = Modifier.size(16.dp))
Box(Modifier.weight(1f)) {
SelectLayoutCrashReproColumn()
}
}
}
@Composable
fun SelectLayoutCrashReproColumn() {
val lazyListState = rememberLazyListState()
LazyColumn(
contentPadding = PaddingValues(top = 4.dp, bottom = 40.dp),
state = lazyListState
) {
items(items = words) { word ->
Column(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
SelectionContainer {
Column(
modifier = Modifier
.wrapContentHeight()
.fillMaxWidth()
.padding(horizontal = 4.dp)
.border(Dp.Hairline, Color.Red),
horizontalAlignment = Alignment.CenterHorizontally
) {
BasicText(
text = "${word.original}:",
style = TextStyle(textAlign = TextAlign.Center),
modifier = Modifier.border(Dp.Hairline, Color.Blue),
)
Spacer(modifier = Modifier.size(4.dp))
BasicText(
text = word.translation,
style = TextStyle(
textAlign = TextAlign.Center,
color = Color.Green,
),
modifier = Modifier.border(Dp.Hairline, Color.Blue),
)
Spacer(modifier = Modifier.size(4.dp))
Spacer(
modifier = Modifier
.fillMaxWidth()
.height(1.dp)
.background(Color.LightGray)
)
}
}
}
}
}
}
se...@gmail.com <se...@gmail.com> #21
compose-foundation = 1.6.1
compose-material = 1.6.1
targetSdk = 34
compileSdk = 34
device Android version: 13
gr...@google.com <gr...@google.com> #22
Thanks, I was able to reproduce it, but it is pretty picky to do so.
- Start touch selection via long press
- Drag the selection out of the text bounds before the selection updates for the first time
- Some logic that expects a previous selection is unable to resolve correctly, and throws the error.
At a high level, the previous selection provides two anchor points, start and end, which determine where the selection is. The end anchor is being moved as part of the drag, so we use the start anchor to determine which texts to include in the selection. Since the previous selection is null at this point, our code sees no texts to include in the selection, hence why we end up with an error indicating that the selection layout is empty. Usually when the previous selection is null, it is because we are currently in an onStart
code path where it makes sense that there cannot be a previous selection. The onStart
logic coerces the touch into the bounds of the text, which is why this error never happens in onStart
, since step 2 of the repro instructions - drag out of text bounds - can't happen. This is what was fixed in
The new problem seems to be the assumption that previousSelection
will be set to a non-null value as part of the gesture onStart
. It seems that it may be possible that the onDrag
occurs before the start has finished updating previousSelection
, leaving it as null
for the onDrag
.
ap...@google.com <ap...@google.com> #23
Branch: androidx-main
commit 4e6fa50899bd258fd2614df2aae99b3ebf5b686f
Author: Grant Toepfer <grantapher@google.com>
Date: Tue Mar 05 15:49:57 2024
Update SelectionManager immediately when selection changes
SelectionManager's selection could be out of sync with gestures since the update of its selection is done in composition. Multiple gesture frames could happen between composition frames, causing unexpected code ordering chronologically.
Fixes:
Test: Added to MultiTextMinTouchBoundsSelectionGesturesTest
Change-Id: Icdf907784adf27d418cd140864c1778dd73a9ec5
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/selection/gestures/MultiTextMinTouchBoundsSelectionGesturesTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
pr...@google.com <pr...@google.com> #24
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.6.4
androidx.compose.foundation:foundation-android:1.6.4
androidx.compose.foundation:foundation-desktop:1.6.4
androidx.compose.foundation:foundation:1.7.0-alpha05
androidx.compose.foundation:foundation-android:1.7.0-alpha05
androidx.compose.foundation:foundation-desktop:1.7.0-alpha05
gr...@google.com <gr...@google.com> #25
If you find more issues in versions greater than or equal to the above, please create a new bug that may contain references to this one.
Description
Jetpack Compose version: 1.6.0
Jetpack Compose component(s) used: androidx.compose.foundation
Android Studio Build: Android Studio Hedgehog | 2023.1.1 Patch 2
Kotlin version: 1.9.22
Steps to Reproduce or Code Sample to Reproduce:
Unfortunately I cannot give instructions on how to reproduce this issue and also don't know for sure where exactly this comes from in my app. I am using quite a lot of compose UI inside classic Fragments and/or ComposeViews. I only see it in my sentry logging. This crash happened on a Galaxy S9+ running Android 10. If you can give me a hint how I can provide more information, please let me know.
Might be related to https://issuetracker.google.com/issues/299787906
Stack trace (if applicable):