Fixed
Status Update
Comments
si...@google.com <si...@google.com>
ex...@gmail.com <ex...@gmail.com> #2
I discovered a different exception on a modified version of my example: If I include some text in the Text
and long press on the blank area of the Text
I get the exception below. For some reason though, it only happens on a device (Pixel 2 in my case, Android 11) and not in the emulator (Pixel 2, Android 11, API 30).
This is from logcat with my device hooked up to AS through USB (my app crashes even when NOT connected to AS):
java.lang.IllegalArgumentException: Start(20) or End(21) is out of range [0..20), or start > end!
at androidx.compose.ui.text.MultiParagraph.getPathForRange(MultiParagraph.kt:252)
at androidx.compose.foundation.text.TextDelegate$Companion.paintBackground(TextDelegate.kt:292)
at androidx.compose.foundation.text.TextController$drawTextAndSelectionBehind$1.invoke(CoreText.kt:511)
at androidx.compose.foundation.text.TextController$drawTextAndSelectionBehind$1.invoke(CoreText.kt:493)
at androidx.compose.ui.draw.DrawBackgroundModifier.draw(DrawModifier.kt:100)
at androidx.compose.ui.node.ModifiedDrawNode.performDraw(ModifiedDrawNode.kt:102)
at androidx.compose.ui.node.LayoutNodeWrapper$invoke$1.invoke(LayoutNodeWrapper.kt:220)
at androidx.compose.ui.node.LayoutNodeWrapper$invoke$1.invoke(LayoutNodeWrapper.kt:219)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:1787)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:116)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:75)
at androidx.compose.ui.node.LayoutNodeWrapper.invoke(LayoutNodeWrapper.kt:219)
at androidx.compose.ui.node.LayoutNodeWrapper.invoke(LayoutNodeWrapper.kt:51)
at androidx.compose.ui.platform.RenderNodeApi29.record(RenderNodeApi29.android.kt:156)
at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:221)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:663)
at android.view.View.draw(View.java:22353)
at android.view.View.updateDisplayListIfDirty(View.java:21226)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4500)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4473)
at android.view.View.updateDisplayListIfDirty(View.java:21186)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4500)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4473)
at android.view.View.updateDisplayListIfDirty(View.java:21186)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4500)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4473)
at android.view.View.updateDisplayListIfDirty(View.java:21186)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4500)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4473)
at android.view.View.updateDisplayListIfDirty(View.java:21186)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:559)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:565)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:642)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4101)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3828)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3099)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:731)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
qq...@google.com <qq...@google.com> #3
Created a CL to fix this problem, need to write tests.
Crash of longpress the empty text is fixed by return null selection if text is empty.
Crash of longpress the blank area is fixed by selecting the whole text content which matches Android TextView behavior.
Crash of longpress the empty text is fixed by return null selection if text is empty.
Crash of longpress the blank area is fixed by selecting the whole text content which matches Android TextView behavior.
qq...@google.com <qq...@google.com>
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 6bc981cbb761c52f0673ada43eb6d86b6dc8a68e
Author: Qingqing Deng <qqd@google.com>
Date: Tue May 11 22:43:51 2021
[Text Selection] Fix crashes of longpress the blank area in non-empty text.
Bug:187437299
Test: Manually tested.
Test: ./gradlew test
RelNote: Fix crashes of longpress the blank area in non-empty text.
Change-Id: I33ab5d732fc3564ec4fe99b16234a980f51684a8
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelection.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegate.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/Selectable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrar.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrarImpl.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextSelectionLongPressDragTest.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerDragTest.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerTest.kt
https://android-review.googlesource.com/1704965
Branch: androidx-main
commit 6bc981cbb761c52f0673ada43eb6d86b6dc8a68e
Author: Qingqing Deng <qqd@google.com>
Date: Tue May 11 22:43:51 2021
[Text Selection] Fix crashes of longpress the blank area in non-empty text.
Bug:187437299
Test: Manually tested.
Test: ./gradlew test
RelNote: Fix crashes of longpress the blank area in non-empty text.
Change-Id: I33ab5d732fc3564ec4fe99b16234a980f51684a8
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelection.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegate.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/Selectable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrar.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionRegistrarImpl.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/TextSelectionLongPressDragTest.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerDragTest.kt
M compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/text/selection/SelectionManagerTest.kt
qq...@google.com <qq...@google.com>
ex...@gmail.com <ex...@gmail.com> #5
This is marked "fixed" but still occurs on beta09.
ex...@gmail.com <ex...@gmail.com> #6
The behavior I described in
ha...@google.com <ha...@google.com>
si...@google.com <si...@google.com>
si...@google.com <si...@google.com>
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
commit 80cb74fe3f3e5c60d0a7e1da4007d54c170485ce
Author: Haoyu Zhang <haoyuchang@google.com>
Date: Fri Jul 30 19:09:35 2021
Fix: Selection long press on empty Text crashes the app
Also refactor some test cases where setContent is not needed.
Bug: 187437299
Test: ./gradlew compose:foundation:foundation:connectedAndroidTest
Change-Id: I3099d7cc9fb94dcc33408a15d106c5fee469a168
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegateTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegate.kt
https://android-review.googlesource.com/1783874
Branch: androidx-main
commit 80cb74fe3f3e5c60d0a7e1da4007d54c170485ce
Author: Haoyu Zhang <haoyuchang@google.com>
Date: Fri Jul 30 19:09:35 2021
Fix: Selection long press on empty Text crashes the app
Also refactor some test cases where setContent is not needed.
Bug: 187437299
Test: ./gradlew compose:foundation:foundation:connectedAndroidTest
Change-Id: I3099d7cc9fb94dcc33408a15d106c5fee469a168
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegateTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/MultiWidgetSelectionDelegate.kt
Description
Compose beta06, AS Canary 14
A long press on an empty
Text
in aSelectionContainer
causes "IllegalArgumentException: Cannot coerce value to an empty range: maximum -1 is less than minimum 0."