Skip to content

fix(ExportDialogFragment.kt) : TransactionTooLargeException #20984

Open
Alok-Silswal wants to merge 1 commit intoankidroid:mainfrom
Alok-Silswal:fix-exportdialog-idsfile
Open

fix(ExportDialogFragment.kt) : TransactionTooLargeException #20984
Alok-Silswal wants to merge 1 commit intoankidroid:mainfrom
Alok-Silswal:fix-exportdialog-idsfile

Conversation

@Alok-Silswal
Copy link
Copy Markdown
Contributor

Purpose / Description

Export Dialog crashed when >60k browsed cards are selected and the user puts the app in the background.

Fixes

Approach

Imitated the approach used in FindAndReplaceDialogFragment.kt to deal with this issue by using class IdsFile rather than using Bundle, which was overflowing when the capacity exceeded, thereby causing the crash.

How Has This Been Tested?

Tested on my phone (Android 14, Xiaomi / HyperOS) using a debug build.

I reproduced the issue. It

  • directed me to the main screen: when I waited for some time (maybe 10 seconds or so)
  • showed error/crash: when I re-opened instantly

Both these observations have been tested. Video attached as evidence.

Learning (optional, can help others)

In ExportDialogFragment.kt, there is a scope for code refactoring and cleanup. This would have shrunk this PR by some lines. But I intentionally avioided it in this PR as it do not fit in this scope.

Export_dialog_app_reopen_issue_resolved.mp4

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

Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't handle the case where the IdsFile is deleted, so getIds() fails

}

/** Attempt to delete the associated [IdsFile] and logs the result */
private fun removeIdsFile() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't copy/paste code, make an extension method

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not able to understand this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is copy/pasted from:

/** Attempt to delete the associated [IdsFile] and logs the result */
private fun removeIdsFile() {
runCatching { idsFile.delete() }
.onFailure { throwable ->
Timber.w(
throwable,
"Exception when removing IdsFile of FindAndReplaceDialogFragment",
)
}.onSuccess { status ->
Timber.i("FindAndReplaceDialogFragment associated IdsFile was deleted: $status")
}
}

Instead, define idsFile.removeSafely(), either as a method on the class, or an extension method

fun IdsFile.removeSafely() {
   // code
}

Comment on lines +337 to +343
BundleCompat.getParcelable(
requireArguments(),
ARG_IDS_FILE,
IdsFile::class.java,
) ?: error("IdsFile missing")

val ids = idsFile.getIds()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val ids = requireArguments().requireParcelable(ARG_IDS_FILE).getIds()

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when reopening the app with certain dialogs in the browser and >60,000 cards selected

2 participants