Repository navigation
Description
Crashlytics issue id: a34175e57d4cd343ec43f9d330ccada0 (Android, dev.opencode.mobile)
Console: https://console.firebase.google.com/project/opencode-mobile-release/crashlytics/app/android:dev.opencode.mobile/issues/a34175e57d4cd343ec43f9d330ccada0
Summary
Fatal java.lang.IndexOutOfBoundsException: Index 19 out of bounds for length 19 thrown from Compose text selection, triggered by a mouse selection gesture inside a SelectionContainer.
- Blame frame:
jdk.internal.util.Preconditions.outOfBounds, reached fromArrayList.getinandroidx.compose.foundation.text.selection.MultiSelectionLayout.getCrossStatus(SelectionLayout.kt:184). - First seen 2026-11-01 18:33 CET. Crashlytics flags it
SIGNAL_FRESH.
java.lang.IndexOutOfBoundsException: Index 19 out of bounds for length 19
at java.util.ArrayList.get (ArrayList.java:434)
at androidx.compose.foundation.text.selection.MultiSelectionLayout.getCrossStatus (SelectionLayout.kt:184)
at androidx.compose.foundation.text.selection.MultiSelectionLayout.startOrEndSlotToIndex (SelectionLayout.kt:295)
at androidx.compose.foundation.text.selection.MultiSelectionLayout.getStartInfo (SelectionLayout.kt:188)
at androidx.compose.foundation.text.selection.SelectionAdjustment$Companion.None$lambda$0 (SelectionAdjustment.java:46)
at androidx.compose.foundation.text.selection.SelectionManager.updateSelection (SelectionManager.kt:1447)
at androidx.compose.foundation.text.selection.SelectionManager.startSelection (SelectionManager.kt:1406)
at androidx.compose.foundation.text.selection.SelectionRegistrarImpl.notifySelectionUpdateStart (SelectionRegistrarImpl.kt:233)
at androidx.compose.foundation.text.modifiers.SelectionModifierNodeKt$DefaultMouseSelectionObserver$1.onStart (SelectionModifierNode.kt:254)
at androidx.compose.foundation.text.selection.SelectionGesturesKt.mouseSelection (SelectionGestures.kt:294)
at androidx.compose.foundation.text.selection.SelectionGesturesKt$awaitSelectionGestures$2.invokeSuspend (SelectionGestures.kt:124)
... frames omitted ...
Counts (Crashlytics, as of 2026-11-02 09:12 CET)
- 1 event / 1 user, on 1.3.1 (35), the newest Android release build (Android Release run 35,
31c38b72cb). Build 35 has 1136 sessions / 245 users in Crashlytics since 2026-10-27. - Device: Lenovo TB320FC (Legion Tab), Android 15, portrait, foreground. Breadcrumbs: the user opened a session from Home a few times, then crashed in
session_chatabout 50 s later.
Root-cause hypothesis
This is a Compose Foundation bug in multi-selectable selection. Our code is involved only because it puts many Text selectables in one SelectionContainer. The mouse path (mouseSelection → DefaultMouseSelectionObserver.onStart) starts a selection at the press position. When the press lands below/after the last selectable in the container, the start slot resolves to selectables.size, and MultiSelectionLayout.getCrossStatus indexes past the end: here, slot 19 of 19 selectables. The same crash is tracked upstream for Compose Multiplatform as CMP-10573 ("SelectionContainer IndexOutOfBoundsException from MultiSelectionLayout.crossStatus when the mouse is pressed below the last…"), fixed there in JetBrains/compose-multiplatform-core#3268 / #3270. Touch input uses a different gesture path, which explains why only a mouse/trackpad tablet user hits it.
Where this happens in our code: OpenCodeRenderedMarkdown wraps all markdown blocks of an assistant message in one SelectionContainer (ui/components/chat/OpenCodeRenderedMarkdown.kt, around line 168). Each paragraph, heading or list item adds a selectable, which fits 19 selectables. A press on bubble padding, a code block, a divider or a gallery after the last text block is enough. OpenCodeAssistantMessage.kt (plain-text fallback), ToolResultSheet.kt and OpenCodeSessionComposer.kt also use SelectionContainer and should get the same guard.
Compose BOM is 2026.09.00 both in run 35 and on main (e8d512b). The SelectionContainer wrapping is unchanged on main, so no fix is merged.
Possible fixes:
- Check whether a newer Compose Foundation (BOM) release contains the upstream fix, and bump.
- Until then, guard against it: for example, don't let mouse presses outside the text bounds start a selection, or give each markdown block its own
SelectionContainer, or catch the case around the selection container. - Related: Keyboard and mouse support #869 (keyboard and mouse support).
Activity
Stop mouse presses below the last text crashing Android selection
ivanfenenko commentedon Nov 3, 2026
Crashlytics triage 2026-11-03: fix PR #945 (
c2347c750a, merged 2026-11-02) closed this issue. It turns offComposeFoundationFlags.isMouseSelectionBetweenTextEnabledthroughComposeFoundationWorkarounds.31c38b72cb), and it's behindc2347c750a.a34175e5is still 1 event / 1 user, on 1.3.1 (35) only. Build 35 has had about 1452 sessions.c2347c750ahas been out for at least 7 days with real usage and 0 events.970e0c4eis also in Compose text selection. It's anIllegalArgumentException: Start(14) or End(0) is out of range [0..22)fromSelectionController.draw→TextLayoutResult.getPathForRange, with 1 event on 1.2.1 (33), Android 12, Xiaomi. It's below the filing threshold, so I haven't filed an issue for it.ivanfenenko commentedon Nov 4, 2026
Crashlytics triage, 2026-11-04: the fix is now in a release build.
ivanfenenko commentedon Nov 6, 2026
Crashlytics triage, 2026-11-06: a34175e5 has a second event, 2 events / 1 user in total, still no event on a build with the fix.
IndexOutOfBoundsException: Index 49 out of bounds for length 49). Build 35 predatesc2347c750a, so this is not a regression.c2347c750a) has 400 sessions and 0 a34175e5 events. Build 37 was released 2026-11-03 11:40 CET, so the earliest close-confirm is 2026-11-10 11:40 CET.ivanfenenko commentedon Nov 11, 2026
Crashlytics triage, 2026-11-11: close-confirmed.
c2347c750a(Android: stop mouse presses below message text crashing selection #945) ships in Android 1.4.0 (37), built 2026-11-03, so it has been out more than 7 days.ComposeFoundationWorkarounds.ktstill setsisMouseSelectionBetweenTextEnabled = false.Leaving this issue closed.