Repository navigation
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
OutOfMemoryErrorondevin a 512 MB test JVM, and pass with the fix.scripts/check.shpasses. Not reproduced on a phone.Part of #253