Status Update
Comments
ae...@google.com <ae...@google.com>
ka...@sz.de <ka...@sz.de> #2
Branch: androidx-main
commit cb1afd67dacbf14cd22206c6f5b543dbf18cec1f
Author: Tony Mak <tonymak@google.com>
Date: Thu Jan 06 14:52:58 2022
Deprecate all the APIs in textclassifier
Bug: 210509084
Test: Check api/current.txt and ensure all classes are deprecated
Relnote: "Deprecate all the APIs in the textclassifier module"
Change-Id: Idc18063196531c0e926162fefeadf2dc5f559da1
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/TextSelection.java
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/TextLinks.java
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/TextClassificationSessionId.java
M textclassifier/textclassifier/api/public_plus_experimental_current.txt
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/TextClassification.java
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/TextClassificationManager.java
M textclassifier/textclassifier/api/current.txt
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/TextClassificationContext.java
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/TextLinksParams.java
M textclassifier/textclassifier/api/restricted_current.txt
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/ConversationAction.java
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/TextClassifier.java
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/ConversationActions.java
M textclassifier/textclassifier/src/main/java/androidx/textclassifier/ExtrasUtils.java
ha...@google.com <ha...@google.com>
gr...@google.com <gr...@google.com> #3
Is there any update when the alpha04 will be available? We need it to target api 31 because of the PendingIntent mutability flags missing in alpha03.
lo...@gmail.com <lo...@gmail.com> #4
I'll schedule it for the next release. Note that alpha04
is a complete turn-down of the library where all APIs are marked as Deprecated
, so you'll also want to start removing your usages of the library.
gr...@google.com <gr...@google.com> #5
Branch: androidx-main
commit 19ed7e69823a09f3c63f8c8cdf339af8ca1645ab
Author: Alan Viverette <alanv@google.com>
Date: Mon Mar 14 15:18:16 2022
Bump textclassifier for final release and turn-down
Bug: 210509084
Change-Id: Ib8b2386903bb49baa3211f7de7fe1587fdda1483
Test: ./gradlew checkApi
M libraryversions.toml
eb...@gmail.com <eb...@gmail.com> #6
Bugjuggler: wait until 2022-03-23
gr...@google.com <gr...@google.com> #7
gr...@google.com <gr...@google.com> #8
Is there a replacement or should we just abandon TextClassifier for android older than API Level 26 ?
eb...@gmail.com <eb...@gmail.com> #9
Abandon. The owning team had no plans to release a replacement library.
lo...@gmail.com <lo...@gmail.com> #10
Our code is pretty simple:
SelectionContainer(
modifier = Modifier.weight(1f)
) {
Text(text = description)
}
There are some Rows/Columns around and the Compose code is set to a androidx.compose.ui.platform.ComposeView
which is collapsed to a height of 0, but nothing special. It's tightly coupled with our project so it's not easy to show a small example code/project.
What I noticed is that this issue only happened on Samsung devices (Galaxy S9+, S20, S20 FE, S21+ 5G) so far. Maybe there is some specific implementation detail they are doing differently. But maybe that's also just coincidence.
gr...@google.com <gr...@google.com> #11
Still no luck. I would be surprised if it was a samsung device thing, this code is pretty solidly in Compose.
I tried more ways of getting 0 size layouts and none of them worked. Also tried getting a lazy list to forget a text that was under a gesture, but it cancels the gesture correctly.
gr...@google.com <gr...@google.com> #12
Some more notes about these code paths, In order to get to the point of "empty layout builder":
- All Texts must be ruled out in one way or another in the selection container logic. Most examples here only have a single text in a selection container, so only the one has to be excluded from the container for it to be empty.
- One possibility is that there are no selectables in the first place.
- In order for the drag to happen, it implies that there is some BasicText available for it to happen on, so this seems unlikely. Could this run after the basic text is unsubscribed from the selection registrar? also seems unlikely.
- Layout coordinates not being attached or not existing at all is another reason for one to be excluded, but this is checked much earlier in the stack trace, so is also unlikely.
- TextLayoutResult being null is the last reason for being excluded, but it is set at the first measure of the composable, and the gesture happening after the gesture is initiated and before the text is measured seems very unlikely.
gr...@google.com <gr...@google.com> #13
All that being said, if anyone can repro this or narrow down the conditions required to repro it, please comment :)
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):