Skip to content

fix(server): stop encoding an oversized transcript cache entry whole - #285

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

Tarquinen merged 1 commit into
devfrom
crash-253

Conversation

@Tarquinen

Copy link
Copy Markdown
Member

The app could crash on a background thread with an out-of-memory error while saving the transcript cache to disk (Google Play reports on v0.7.0 and v0.8.0). The writer turned each cached session into one big string before checking it against the cache's 4 MB file limit. A session with inline images (for example tool screenshots) or long tool output can be tens of megabytes, and encoding it needs several times that in memory, all to be thrown away for being over the limit.

Now a session whose images and texts alone already pass the space left is skipped without encoding it, and the rest stream into a buffer capped at that space, stopping as soon as a session passes it. The file holds the same entries as before.

Two new tests (an entry far over the limit, and one 120 MB inline image) both crash with OutOfMemoryError on dev in a 512 MB test JVM, and pass with the fix. scripts/check.sh passes. Not reproduced on a phone.

Part of #253

The transcript cache's disk writer encoded each session's entry to a
String before checking it against the 4 MB file limit. An entry with
inline images or long tool output could be tens of megabytes, and
encoding it needed several times that in memory, so the background
writer could run out of memory, only to throw the result away.

Now an entry whose images and texts alone already pass the space left
is skipped without encoding, and the rest stream into a buffer capped
at that space, stopping as soon as an entry passes it.

Verified: two new TranscriptCachePersistenceTests cases (an entry far
over the limit, and one 120 MB inline image) hit OutOfMemoryError on
dev in a 512 MB test JVM and pass with the fix. vm.sh check passes.
Not reproduced on a phone.

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