ankidroid / ankidroid/Anki-Android
Export dialog deletes its selected-ids file on configuration change, causing a crash
- Vorherrschende Sprache
- Kotlin
- Sterne
- 11.8k
- Forks
- 2.9k
- Ø Merge
- 2 T. 3 Std.
- Gemergte PRs (30 T.)
- 171
Beschreibung
### Checked for duplicates?
- [x] This issue is not a duplicate
### Does it also happen in the desktop version?
- [x] This bug does not occur in the latest version of Anki Desktop
### What are the steps to reproduce this bug?
1. open Card Browser
2. select one or more notes/cards (long press then tap)
3. open the Export dialog for the selection
4. rotate the device (or trigger a config change) while the dialog is open
5. tap Export in the recreated dialog
### Expected behaviour
expected: export completes normally, same as if you hadnt rotated.
actual: it crashes / fails, because the file holding the selected ids gets deleted during the
rotation.
ExportDialogFragment.onDismiss() (AnkiDroid/src/main/java/com/ichi2/anki/export/ExportDialogFragment.kt
lines 69-74) calls removeIdsFile() whenever the dialog is dismissed:
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
if (arguments?.containsKey(ARG_IDS_FILE) == true) {
removeIdsFile()
}
}
problem is DialogFragment.onDestroyView() calls onDismiss() on every configuration change, not
just on an actual dismiss. so rotating deletes the ids file, but the dialog gets recreated with
the same arguments (same file path). tapping Export after that calls getIds() on a file that no
longer exists and throws FileNotFoundException with nothing catching it.
wrote a Robolectric test that confirms this - built the fragment, called scenario.recreate() to
simulate the config change, and the ids file was gone afterwards. also compared with
FindAndReplaceDialogFragment which uses the same IdsFile mechanism but deletes it on explicit
cancel/submit instead of onDismiss, so it doesnt have this problem
### Debug info
```text
AnkiDroid Version = 2.24.0 (ebcf8e0e34921628b9b8a496c66ffd4adbb3705f)
Backend Version = 0.1.64-anki25.09.2 (25.09.2 3890e12c9e48c028c3f12aa58cb64bd9f8895e30)
Android Version = 13 (SDK 33)
ProductFlavor = play
Device Info = OnePlus | OnePlus | OP555BL1 | IV2201_IND | IV2201 | mt6877
WebView Info = [com.google.android.webview | 787118103]: Mozilla/5.0 (Linux; Android 13; IV2201 Build/TP1A.220905.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/150.0.7871.181 Mobile Safari/537.36
ACRA UUID = bbe8603c-4564-4f9f-9621-e2c7e5b9b556
FSRS = 5.1.0 (Enabled: false)
Crash Reports Enabled = true
```
### (Optional) Anything else you want to share?
https://github.com/user-attachments/assets/c62b1583-0d85-4861-8d8c-4c214800c58b
### Research
- [x] I have checked the [manual](https://docs.ankidroid.org/) and the [FAQ](https://github.com/ankidroid/Anki-Android/wiki/FAQ) and could not find a solution to my issue
- [x] (Optional) I have confirmed the issue is not resolved in the latest alpha release ([instructions](https://docs.ankidroid.org/manual.html#betaTesting))
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.