fix: prevent TransactionTooLargeException when attaching a file while replying to a message with a large HTML quote - #11263
Conversation
… replying to a message with a large HTML quote
|
Missing report label. Set exactly one of: |
|
Hi @mvanhorn, Any news when this issue will be solved? Thanks, |
|
@mvanhorn Thanks for finding the source of the issue and proposing a quick fix. This prevents the crash, but does so by silently omitting oversized quoted HTML from the saved state. After activity recreation, this could alter the composed message or cause part of its state to be lost. |
The previous fix avoided TransactionTooLargeException by dropping quoted HTML above a size threshold, which prevents the crash but silently loses part of the composed message across activity recreation. Keep large composer content out of the bundle entirely. The saved state now carries only a draft reference, and the composer restores its working state from that draft. When restoring this way, saving of the composer view hierarchy is disabled so the content cannot be written back into the bundle by the view layer. Replaces the size-threshold tests with one asserting the saved state carries only quote restoration metadata.
|
You were right that the size cutoff was the wrong shape. Trading a crash for silent content loss is not a fix, and an arbitrary threshold would have been a permanent source of "my reply lost the quoted part" reports. Pushed 8ebaeff taking the approach you described instead.
On verification, so you know exactly what has and has not been checked: Two things I am unsure about and would value your view on: whether restoring from draft should also cover the case where no draft has been saved yet at recreation time, and whether disabling parent save on the whole composer container is too broad a hammer compared with targeting the specific views. |
Contribution Summary
Linked Issue/Ticket: Fixes #9425
Description
In
QuotedMessagePresenter.onSaveInstanceStatethe offending line isoutState.putSerializable(STATE_KEY_HTML_QUOTE, quotedHtmlContent). Guard this put by the character length of the quoted content (quotedHtmlContent.getQuotedContent()): only persist the HTML quote into the saved-stateBundlewhen it is below a safe threshold well under the Binder limit (e.g. a ~256 KB / ~262144-char cap defined as a constant), and skip the put when it is larger. This eliminates the oversized parcel and therefore the crash. To keep the size check unit-testable without standing up the full presenter (whose constructor pulls DI singletons and aMessageCompose/view), extract the decision into a small pure helper (e.g. a package-visible staticshouldPersistQuotedHtml(InsertableHtmlContent, int maxChars)/ size computation) thatonSaveInstanceStatecalls.onRestoreInstanceStatealready null-checksquotedHtmlContent, so when the quote was skipped the composer degrades gracefully rather than crashing: the user's typed text (saved separately by theEditText) is preserved, and only the rarely-hit "process killed while the picker is open, then recreated" path loses the re-displayable quote - an acceptable trade versus a guaranteed crash on every attach.MessageCompose.javais the caller ofonSaveInstanceStatebut requires no change, so it is intentionally excluded from the scope list.Screen Shots
N/A - no UI change; the fix guards saved-state serialization of the quoted-HTML in
QuotedMessagePresenter.AI Disclosure
Select one of the following (mandatory)
Contribution Checklist