ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.16k stars 2.17k forks source link

[BUG]: Random mistaken "Failed to load xxx.bin" toast messages when using JS API #16510

Open silidev opened 1 month ago

silidev commented 1 month ago

Checked for duplicates?

Does it also happen in the desktop version?

What are the steps to reproduce this bug?

Use the JS API a lot. It only happens randomly. Maybe it is possible to reproduce it reliably by calling some harmless API method in a loop.

Expected behaviour

No error message should be displayed.

Actual behaviour

Sometimes (no discernible pattern) AnkiDroid will throw a "Card Content Error: Failed to load 'xxx.bin'" warning, despite everything working fine. xxx being a name referring to an element of the JS API, e.g . "cardDue.bin", "cardMod.bin", "ttsSetLanguage". Maybe all strings from the jsApiList in AnkiDroid/src/main/assets/scripts/js-api.js are possible.

Debug info

AnkiDroid Version = 2.18.0 (464cf290cc77c3f2c562cb03b408b78a13be261b)

Backend Version = 0.1.38-anki24.04.1 (24.04.1 ccd9ca1a8309b80bcb50ddc5d99c7ce63440bce9)

Android Version = 13 (SDK 33)

ProductFlavor = full

Manufacturer = Google

Model = Pixel 4a

Hardware = sunfish

Webview User Agent = Mozilla/5.0 (Linux; Android 13; Pixel 4a Build/TQ3A.230805.001.S1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.179 Mobile Safari/537.36

ACRA UUID = 4d6cad38-e805-4913-82fe-99652a272d86

FSRS Enabled = true

Crash Reports Enabled = true

(Optional) Anything else you want to share?

I am pretty sure this began with JS-API 0.2 or 0.3.

This is the string: Card Content Error: Failed to load ‘%s’

This issue is related: https://github.com/ankidroid/Anki-Android/issues/10033

WhatsApp Image 2024-05-30 at 22 18 58_9a9ce0e9

Research

david-allison commented 1 month ago

@silidev Could you provide a sample deck?

For diagnostics:

https://github.com/ankidroid/Anki-Android/blob/0c9d8a15501e222064cc44e6c55eca53f23bbc79/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt#L2287

silidev commented 1 month ago

Yes, I will build one and put it here. Thanks for looking into this. 🙂

David Allison @.***> schrieb am So., 2. Juni 2024, 22:14:

@silidev https://github.com/silidev Could you provide a sample deck?

— Reply to this email directly, view it on GitHub https://github.com/ankidroid/Anki-Android/issues/16510#issuecomment-2144007516, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2V77XC73VELBPW5EJ5W2LZFN4IRAVCNFSM6AAAAABIRTBDI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBUGAYDONJRGY . You are receiving this because you were mentioned.Message ID: @.***>

silidev commented 1 month ago

Hi David! Unfortunately, I cannot reproduce it in my sample deck. My production collection is not suitable for testing by others. I hope I find time to build my own AnkiDroid from source. Then I will try to fix it myself and test it in my production collection. I guess you best close this issue for now. Thanks again for having a look at this.

david-allison commented 1 month ago

I can get a slight reproduction with a CACHE_MISS error with showAnswer when attaching Chrome Dev tools

Let's leave this open, I know where it needs to be fixed, but I don't know why

@silidev Can you use logcat? I could add some diagnostic logs instead, which can be used to resolve this

silidev commented 1 month ago

@david-allison I never used logcat, but I have used the adb command line before and guess that it won't be that difficult, will it?

silidev commented 1 month ago

@david-allison By the way: Kind of the deeper reason, why this is a problem at all, is this: the toast message with the error is very low on the screen, hiding the answer buttons. If it would be positioned higher on the screen everything would be just fine.

Other toast messages are also a somewhat annoying, like "1 card rescheduled". In the current position the toast message is hiding the answer buttons. If it would be a little bit higher, higher than the answer buttons, it would be no problem it all. I understand that you are interested what is causing the error, but repositioning the toast message display to a higher Y-position would improve the user experience for all types of toast messages.