Skip to content

Stop the phone crashing on a reply line that starts with a mousse:// link - #54

Merged
TheAnimatrix merged 1 commit into
mainfrom
fix/link-chip-start
Dec 1, 2026
Merged

TheAnimatrix merged 1 commit into
mainfrom
fix/link-chip-start

Conversation

@TheAnimatrix

Copy link
Copy Markdown
Collaborator

On Android, a thread crashes the app when a paragraph or list item in a reply starts with a mousse:// link. The demo's links thread (t-links) crashes on main as soon as it opens.

Cause

InlineText builds the text with chips from pieces of the reply. When a link starts the paragraph, the piece before it is empty. AnnotatedString.subSequence(0, 0) still carries the link it touches, as a link of no length. Compose's TextLinkScope then asks for the box at offset -1 and throws:

IllegalArgumentException: offset(-1) is out of bounds [0, 33)
  at MultiParagraph.getBoundingBox
  at TextLinkScope.pathForRangeInRangeCoordinates

Fix

  • The piece-building moves into withChips (MessageLinks.kt), which never appends an empty piece.
  • Marks with no length are skipped.
  • iOS draws links differently and doesn't have this bug.

Verification

  • New MessageLinksTest covers a link at the start, at the end, and two side by side, each with and without chips. No piece may carry a link of no length, and the text must stay the same.
  • Must-fail control: with the empty pieces appended again (the old code), both tests fail (18 tests completed, 2 failed). With the fix, all pass.
  • scripts\android.ps1 test and build debug pass.
  • Emulator (API 36): main crashes opening studio/thread/t-links. With this fix it opens with every chip, and the crash log stays empty.

No issue

@TheAnimatrix
TheAnimatrix merged commit f3ece23 into main Dec 1, 2026
3 checks passed
@TheAnimatrix
TheAnimatrix deleted the fix/link-chip-start branch December 1, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant