-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Checked for duplicates?
- This issue is not a duplicate
What are the steps to reproduce this bug?
- Create a card with the following contents on it somewhere:
<script>
const STORAGE_KEY = "example-storage-location";
let existing_storage = localStorage.getItem(STORAGE_KEY);
if (existing_storage === null) {
existing_storage = 0;
} else {
existing_storage = parseInt(existing_storage);
}
console.log("This template has been accessed " + existing_storage + " times.");
existing_storage = existing_storage + 1;
localStorage.setItem(STORAGE_KEY, existing_storage);
console.log(STORAGE_KEY + " set to " + existing_storage);
</script>- Connect phone in debug mode.
- Open
chrome://inspecton phone and check the console logs. - Go to front, back, multiple cards, etc.
- Exit deck to list of decks
- Select same deck, repeat steps 2-4.
Expected behaviour
The console should say: "This template has been accessed 0 times", then increment by 1 for each time the template is accessed (once for front, once for back, etc). The number should not reset when you exit and then re-enter the deck.
Actual behaviour
All localStorage seems to be lost when exiting the deck.
Debug info
AnkiDroid Version = 2.17.5 (1c1aa94ec466f37d33fd2f75020d9f9021ac811e)
Backend Version = 0.1.34-anki23.12.1 (23.12.1 1a1d4d5419c6b57ef3baf99c9d2d9cf85d36ae0a)
Android Version = 14 (SDK 34)
ProductFlavor = play
Manufacturer = Google
Webview User Agent = Mozilla/5.0 (Linux; Android 14; Pixel 8 Pro Build/UQ1A.240205.004; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.119 Mobile Safari/537.36
ACRA UUID =
Crash Reports Enabled = true
(Optional) Anything else you want to share?
I have been using localStorage to store persistent per-deck settings, e.g. "Show pictures automatically" or "Play TTS automatically", etc, because depending on the review situation, I want more or less automatic behavior (e.g. if I am in a room where I don't have headphones and I need to be quiet, I don't want TTS going off automatically). This worked in previous versions, but now my settings get lost any time I exit the deck.
Seems like someone else is having the same issue as well, and they appear to be using localStorage to share information across decks.
Research
- I am reporting a bug specific to AnkiDroid (Android app)
- I have checked the manual and the FAQ and could not find a solution to my issue
- (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)