ankidroid / ankidroid/Anki-Android

Export dialog deletes its selected-ids file on configuration change, causing a crash

オープン
#21,477 コメント 5 件 リアクション 0 件 担当者 1 名 @GuTS805 が担当を希望しています GitHub で見る
Needs Triage
主要言語
Kotlin
スター
11.8k
フォーク
2.9k
平均マージ
2日 3時間
マージ済み PR(30日)
171

説明

### 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))

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。