Skip to content

fix: avoid TransactionTooLargeException with many-field note types#21295

Open
criticalAY wants to merge 1 commit into
ankidroid:mainfrom
criticalAY:fix/editor-fields
Open

fix: avoid TransactionTooLargeException with many-field note types#21295
criticalAY wants to merge 1 commit into
ankidroid:mainfrom
criticalAY:fix/editor-fields

Conversation

@criticalAY

@criticalAY criticalAY commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Note

Assisted by Opus 4.6 for tests (test)

Purpose / Description

A note type with a very large number of fields (e.g. ~400) crashes the note editor with TransactionTooLargeException when the editor is stopped i.e. when the app is backgrounded or the previewer is opened so this PR fixes that

Fixes

Approach

FieldEditLine now persists only the essential, user-editable state name, content, ord and expansionState through a compact @Parcelize SavedState, instead of freezing the whole child view subtree and Java-serializing the enum.

How Has This Been Tested?

Unit test and Pixel 10 wasn't able to reproduce the error

Learning (optional, can help others)

NA

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

FieldEditLine.onSaveInstanceState() froze its entire child view
hierarchy and Java-serialized the expansion enum, costing ~1.2 KB per
field even when the field was empty. A note type with 400 fields
serialized to ~500 KB of view state, which exceeded the Binder
transaction limit when the activity was stopped (backgrounded or a
preview opened), crashing with TransactionTooLargeException.

Assisted-By: Claude Opus 4.8 (tests)
@ZornHadNoChoice

Copy link
Copy Markdown
Collaborator

Did you reproduce the bug? The note type in the shared deck has only about 200 fields and it didn't crash the app by leaving or previewing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Note editor crash if too many field

2 participants