Status Update
Comments
cc...@google.com <cc...@google.com> #2
Hello, we're also affected by the same issue.
It seems like this issue has been introduced by Compose Version 1.6.0+, as it didn't occur on our App version which contained Compose version 1.5.4. However, after we updated Compose to 1.6.0+ (specifically 1.6.2) it occured for more than 100 users.
Fatal Exception: java.lang.IllegalStateException: SelectionLayout must not be empty.
at androidx.compose.foundation.text.selection.SelectionLayoutBuilder.build(SelectionLayout.kt:449)
at androidx.compose.foundation.text.selection.SelectionManager.getSelectionLayout-Wko1d7g(SelectionManager.kt:796)
at androidx.compose.foundation.text.selection.SelectionManager.updateSelection-jyLRC_s$foundation_release(SelectionManager.kt:753)
at androidx.compose.foundation.text.selection.SelectionManager.updateSelection-qNKwrvQ$foundation_release(SelectionManager.kt:716)
at androidx.compose.foundation.text.selection.SelectionManager$4.invoke-pGV3PM0(SelectionManager.kt:291)
at androidx.compose.foundation.text.selection.SelectionManager$4.invoke(SelectionManager.kt:278)
at androidx.compose.foundation.text.selection.SelectionRegistrarImpl.notifySelectionUpdate-njBpvok(SelectionRegistrarImpl.kt:209)
at androidx.compose.foundation.text.modifiers.SelectionControllerKt$makeSelectionModifier$longPressDragObserver$1.onDrag-k-4lQ0M(SelectionController.kt:217)
at androidx.compose.foundation.text.selection.SelectionGesturesKt$touchSelection$2.invoke(SelectionGestures.kt:124)
at androidx.compose.foundation.text.selection.SelectionGesturesKt$touchSelection$2.invoke(SelectionGestures.kt:123)
at androidx.compose.foundation.gestures.DragGestureDetectorKt.drag-jO51t88(DragGestureDetector.kt:114)
at androidx.compose.foundation.gestures.DragGestureDetectorKt$drag$1.invokeSuspend(DragGestureDetector.kt:1)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:179)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:168)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:474)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:508)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:497)
at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:368)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl$PointerEventHandlerCoroutine.offerPointerEvent(SuspendingPointerInputFilter.kt:665)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.dispatchPointerEvent(SuspendingPointerInputFilter.kt:544)
at androidx.compose.ui.input.pointer.SuspendingPointerInputModifierNodeImpl.onPointerEvent-H0pRuoY(SuspendingPointerInputFilter.kt:566)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:317)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:303)
at androidx.compose.ui.input.pointer.NodeParent.dispatchMainEventPass(HitPathTracker.kt:185)
at androidx.compose.ui.input.pointer.HitPathTracker.dispatchChanges(HitPathTracker.kt:104)
at androidx.compose.ui.input.pointer.PointerInputEventProcessor.process-BIzXfog(PointerInputEventProcessor.kt:113)
at androidx.compose.ui.platform.AndroidComposeView.sendMotionEvent-8iAsVTc(AndroidComposeView.android.kt:1576)
at androidx.compose.ui.platform.AndroidComposeView.handleMotionEvent-8iAsVTc(AndroidComposeView.android.kt:1527)
at androidx.compose.ui.platform.AndroidComposeView.dispatchTouchEvent(AndroidComposeView.android.kt:1466)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3211)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2883)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3211)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2883)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3211)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2883)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3211)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2883)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3211)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2883)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3211)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2883)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:531)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1896)
at android.app.Activity.dispatchTouchEvent(Activity.java:4216)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:70)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:489)
at android.view.View.dispatchPointerEvent(View.java:14812)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6591)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6392)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5813)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5870)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5836)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5817)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5870)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5836)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6018)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5844)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6075)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5817)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5870)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5836)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5817)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8894)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8843)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8811)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9045)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:260)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:335)
at android.os.Looper.loopOnce(Looper.java:161)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:8005)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1039)
cc...@google.com <cc...@google.com> #3
Can you provide any information on how your SelectionContainer
s are set up? What is between your SelectionContainer
s and the Text
/BasicText
s in your hierarchy?
cc...@google.com <cc...@google.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?
ap...@google.com <ap...@google.com> #5
TextField
or Text
? TextField
s don't have any interaction with SelectionContainer
s, they handle selection themselves. The stack trace indicate Text
or BasicText
being used.
Is it a single Text
within the container? or multiple?
Any other information you can provide on the layout changing? Can it happen during a selection gesture? The stack trace implies that the crash happens during the drag part of a long-press drag directly on the text (not on a handle), not the initial long-press (could be the frame right after the initial long-press though if it moves even a pixel), so I'm curious if there is any layout changing during the gesture.
Is the text scrollable?
Thanks for the information!
ju...@google.com <ju...@google.com> #6
Any other information you can provide on the layout changing?
We are getting these crashes in an open source project and here is all the SelectionContainer uses on the project
And here is a sample crash log, it doesn't contain where this is happening so your question regard where this happens is hard to answer given I can't reproduce the issue but users are getting them per Google Play console, if you have access to Google Play Console's crash logs please have a look at this package crashes: com.byagowi.persiancalendar this is the third crash there of the release v9.1.1. The app is free from Internet and doesn't even get Internet permission in the manifest so should be safe enough for your testing also, and here is the source
Exception java.lang.IllegalStateException: SelectionLayout must not be empty.
at androidx.compose.foundation.text.selection.SelectionLayoutBuilder.build (SelectionLayoutBuilder.java:726)
at androidx.compose.foundation.text.selection.SelectionManager.getSelectionLayout-Wko1d7g (SelectionManager.kt:726)
at androidx.compose.foundation.text.selection.SelectionManager.updateSelection-jyLRC_s$foundation_release (SelectionManager.kt:726)
at androidx.compose.foundation.text.selection.SelectionManager.updateSelection-qNKwrvQ$foundation_release (SelectionManager.kt:44)
at androidx.compose.foundation.text.selection.SelectionManager$4.invoke-pGV3PM0 (SelectionManager.kt:44)
at androidx.compose.foundation.text.selection.SelectionManager$4.invoke (SelectionManager.kt:44)
at androidx.compose.foundation.text.selection.SelectionRegistrarImpl.notifySelectionUpdate-njBpvok (SelectionRegistrarImpl.kt:23)
at androidx.compose.foundation.text.modifiers.SelectionControllerKt$makeSelectionModifier$longPressDragObserver$1.e (SelectionController.kt:53)
at androidx.compose.foundation.text.selection.SelectionGesturesKt$touchSelection$2.invoke (SelectionGestures.kt:17)
at androidx.compose.foundation.text.selection.SelectionGesturesKt$touchSelection$2.invoke (SelectionGestures.kt:17)
at androidx.compose.foundation.gestures.DragGestureDetectorKt.drag-jO51t88 (DragGestureDetector.kt:86)
at androidx.compose.foundation.gestures.DragGestureDetectorKt$drag$1.invokeSuspend (DragGestureDetector.kt:1)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:1)
na...@google.com <na...@google.com> #7
Were there crashes before 9.1.1
release?
If there weren't, from what I can tell, compose foundation (the containing package) went from 1.6.0-rc01
to 1.6.1
, which could help in trying to find what changed.
ge...@gmail.com <ge...@gmail.com> #8
Tried to reproduce by messing with the size of text and visibility in animation (to make the size 0) but was unable to repro even when dragging on a zero size text.
cc...@google.com <cc...@google.com> #9
Were there crashes before 9.1.1 release?
The app had three releases with Compose, v9.0.0, v9.1.0 and v9.1.1 and they all had these crashes per Google Play console (before these versions the app was Compose-free)
da...@emirates.com <da...@emirates.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.
di...@okcredit.in <di...@okcredit.in> #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.
cc...@google.com <cc...@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.
ke...@netflix.com <ke...@netflix.com> #13
All that being said, if anyone can repro this or narrow down the conditions required to repro it, please comment :)
Description
Component used: Macrobench 1.2.0-alpha06, profileInstaller 1.3.0-alpha02
Devices/Android versions reproduced on: Pixel 7 API 33 user build
Running macrobenchmarks with the latest alpha versions is not possible on user builds due to (reproduced in Now In Android and Macrobenchmark samples)