Skip to content

fix(transcript): merge inline runs in linear time - #283

Merged
Tarquinen merged 1 commit into
devfrom
crash-278
Nov 22, 2026
Merged

Tarquinen merged 1 commit into
devfrom
crash-278

Conversation

@Tarquinen

Copy link
Copy Markdown
Member

The app froze ("isn't responding") while showing a reply with a very long paragraph full of plain markers, like snake_case names or stray brackets. Merging the parsed pieces of a paragraph copied the whole merged text again for every piece, and each stray ] did the same to the text before it, so the work grew with the square of the paragraph's length: 352 KB of snake_case text took 1.4 s on the dev VM, and much longer on a phone.

Now merged text is built once with a StringBuilder, and a ] that doesn't close a link stays in the text buffer; the same text parses in 14 ms. Nothing visible changes.

  • Two new MarkdownBlockTests cases (many adjacent runs, many stray ]) time out at 2 s on dev and pass with the fix. Full scripts/check.sh passes.
  • Not reproduced as an actual freeze on a phone or emulator, so this is "part of" rather than "fixes".

Part of #278

A long reply paragraph with many plain markers (snake_case names, stray brackets) froze the
app while its row composed. InlineText.coalesced copied the whole merged string for every run
it merged, and each stray ] appended to the previous text node the same way, so the cost grew
with the square of the paragraph's size: 352 KB of snake_case text took 1.4 s to parse on the
dev VM. Merged text now goes through one StringBuilder, and a ] that doesn't close a link
stays in the text buffer.

Verified: two new MarkdownBlockTests cases (200,000 runs; 150,000 stray ]) time out at 2 s
without the fix and pass with it; the same snake_case text now parses in 14 ms. Full
scripts/check.sh passes. Not reproduced as an ANR on a device.

Part of #278
@Tarquinen
Tarquinen merged commit 67198a9 into dev Nov 22, 2026
3 checks passed
@Tarquinen
Tarquinen deleted the crash-278 branch November 22, 2026 18:03
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