ankidroid / Anki-Android

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

[BUG]: AnkiDroid error when interacting with the API #16318

Open warleysr opened 7 months ago

warleysr commented 7 months ago

Checked for duplicates?

Does it also happen in the desktop version?

What are the steps to reproduce this bug?

I'm creating an app that queries AnkiDroid database to get card content, on my main screen I show the deck list to the user. I have a instance of AddContentApi and call the getDeckList() method. Sometimes when I launch my app a Toast from AnkiDroid appears saying that some error ocurred and a report was being generated.

UPDATE: The AnkiDroid toast keeps appearing very often, sometimes when getting the deck list or when reviewing a card. Checking the Logcat I got this error:

CardContentProvider/ answerCard - RuntimeException on answering card
net.ankiweb.rsdroid.exceptions.BackendInvalidInputException: card was modified: Normal(
    Review(
        ReviewState {
            scheduled_days: 302,
            elapsed_days: 786,
            ease_factor: 2.5,
            lapses: 0,
            leeched: false,
            memory_state: None,
        },
    ),
) Normal(
    Review(
        ReviewState {
            scheduled_days: 3,
            elapsed_days: 87,
            ease_factor: 2.5,
            lapses: 0,
            leeched: false,
            memory_state: None,
        },
    ),
)
    at net.ankiweb.rsdroid.exceptions.BackendInvalidInputException$Companion.fromInvalidInputError(SourceFile:40)
    at net.ankiweb.rsdroid.BackendException$Companion.fromError(SourceFile:105)
    at net.ankiweb.rsdroid.BackendKt.unpackResult(SourceFile:31)
    at net.ankiweb.rsdroid.BackendKt.access$unpackResult(SourceFile:1)
    at net.ankiweb.rsdroid.Backend$runMethodRaw$1.invoke(SourceFile:2)
    at net.ankiweb.rsdroid.Backend$runMethodRaw$1.invoke(SourceFile:1)
    at net.ankiweb.rsdroid.Backend.withBackend(SourceFile:8)
    at net.ankiweb.rsdroid.Backend.runMethodRaw(SourceFile:16)
    at anki.backend.GeneratedBackend.answerCardRaw(SourceFile:9)
    at anki.backend.GeneratedBackend.answerCard(SourceFile:15)
    at com.ichi2.libanki.sched.Scheduler.answerCard(SourceFile:4)
    at com.ichi2.anki.provider.CardContentProvider.answerCard(SourceFile:30)
    at com.ichi2.anki.provider.CardContentProvider.update(SourceFile:43)
    at android.content.ContentProvider.update(Unknown Source:20)
    at android.content.ContentProvider$Transport.update(Unknown Source:41)
    at android.content.ContentProviderNative.onTransact(Unknown Source:612)
    at android.os.Binder.execTransactInternal(Unknown Source:103)
    at android.os.Binder.execTransact(Unknown Source:16)

net.ankiweb.rsdroid.exceptions.BackendInvalidInputException: card was modified: Normal(
    Review(
        ReviewState {
            scheduled_days: 302,
            elapsed_days: 786,
            ease_factor: 2.5,
            lapses: 0,
            leeched: false,
            memory_state: None,
        },
    ),
) Normal(
    Review(
        ReviewState {
            scheduled_days: 3,
            elapsed_days: 87,
            ease_factor: 2.5,
            lapses: 0,
            leeched: false,
            memory_state: None,
        },
    ),
)
    at net.ankiweb.rsdroid.exceptions.BackendInvalidInputException$Companion.fromInvalidInputError(SourceFile:40)
    at net.ankiweb.rsdroid.BackendException$Companion.fromError(SourceFile:105)
    at net.ankiweb.rsdroid.BackendKt.unpackResult(SourceFile:31)
    at net.ankiweb.rsdroid.BackendKt.access$unpackResult(SourceFile:1)
    at net.ankiweb.rsdroid.Backend$runMethodRaw$1.invoke(SourceFile:2)
    at net.ankiweb.rsdroid.Backend$runMethodRaw$1.invoke(SourceFile:1)
    at net.ankiweb.rsdroid.Backend.withBackend(SourceFile:8)
    at net.ankiweb.rsdroid.Backend.runMethodRaw(SourceFile:16)
    at anki.backend.GeneratedBackend.answerCardRaw(SourceFile:9)
    at anki.backend.GeneratedBackend.answerCard(SourceFile:15)
    at com.ichi2.libanki.sched.Scheduler.answerCard(SourceFile:4)
    at com.ichi2.anki.provider.CardContentProvider.answerCard(SourceFile:30)
    at com.ichi2.anki.provider.CardContentProvider.update(SourceFile:43)
    at android.content.ContentProvider.update(Unknown Source:20)
    at android.content.ContentProvider$Transport.update(Unknown Source:41)
    at android.content.ContentProviderNative.onTransact(Unknown Source:612)
    at android.os.Binder.execTransactInternal(Unknown Source:103)
    at android.os.Binder.execTransact(Unknown Source:16)
Handler (android.os.Handler) {d38aed8} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {d38aed8} sending message to a Handler on a dead thread
    at android.os.MessageQueue.enqueueMessage(Unknown Source:59)
    at android.os.Handler.enqueueMessage(Unknown Source:16)
    at android.os.Handler.sendMessageAtTime(Unknown Source:37)
    at android.os.Handler.sendMessageDelayed(Unknown Source:13)
    at android.os.Handler.post(Unknown Source:6)
    at android.widget.Toast$CallbackBinder.onToastHidden(Unknown Source:7)
    at android.app.ITransientNotificationCallback$Stub.onTransact(Unknown Source:21)
    at android.os.Binder.execTransactInternal(Unknown Source:118)
    at android.os.Binder.execTransact(Unknown Source:16)
Slow Binder: BpBinder transact took 794 ms, interface=android.content.pm.IPackageManager, code=5 oneway=false

Expected behaviour

Do not receive error messages when interacting with the API.

Actual behaviour

Toast messages on my app saying that a report is being generated, when I return to the AnkiDroid app a popup asks me if I want to send the report to developers. Even though the error occurs getting the deck list still works.

Debug info

AnkiDroid Version = 2.17.6 (568538896be943818ca793dd2635822265712def)

Backend Version = 0.1.34-anki23.12.1 (23.12.1 1a1d4d5419c6b57ef3baf99c9d2d9cf85d36ae0a)

Android Version = 12 (SDK 31)

ProductFlavor = play

Manufacturer = Xiaomi

Model = M2010J19SG

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 12; M2010J19SG Build/SKQ1.211202.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/123.0.6312.120 Mobile Safari/537.36

ACRA UUID = 5460b21c-2117-47fc-9cf3-908b997ffae9

Crash Reports Enabled = true

(Optional) Anything else you want to share?

No response

Research

welcome[bot] commented 7 months ago

Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing

david-allison commented 7 months ago

Have you checked logcat? Package com.ichi2.anki

warleysr commented 6 months ago

Closing the issue since I was unable to reproduce again.

warleysr commented 6 months ago
CardContentProvider/ answerCard - RuntimeException on answering card
net.ankiweb.rsdroid.exceptions.BackendInvalidInputException: card was modified: Normal(
    Review(
        ReviewState {
            scheduled_days: 302,
            elapsed_days: 786,
            ease_factor: 2.5,
            lapses: 0,
            leeched: false,
            memory_state: None,
        },
    ),
) Normal(
    Review(
        ReviewState {
            scheduled_days: 3,
            elapsed_days: 87,
            ease_factor: 2.5,
            lapses: 0,
            leeched: false,
            memory_state: None,
        },
    ),
)
    at net.ankiweb.rsdroid.exceptions.BackendInvalidInputException$Companion.fromInvalidInputError(SourceFile:40)
    at net.ankiweb.rsdroid.BackendException$Companion.fromError(SourceFile:105)
    at net.ankiweb.rsdroid.BackendKt.unpackResult(SourceFile:31)
    at net.ankiweb.rsdroid.BackendKt.access$unpackResult(SourceFile:1)
    at net.ankiweb.rsdroid.Backend$runMethodRaw$1.invoke(SourceFile:2)
    at net.ankiweb.rsdroid.Backend$runMethodRaw$1.invoke(SourceFile:1)
    at net.ankiweb.rsdroid.Backend.withBackend(SourceFile:8)
    at net.ankiweb.rsdroid.Backend.runMethodRaw(SourceFile:16)
    at anki.backend.GeneratedBackend.answerCardRaw(SourceFile:9)
    at anki.backend.GeneratedBackend.answerCard(SourceFile:15)
    at com.ichi2.libanki.sched.Scheduler.answerCard(SourceFile:4)
    at com.ichi2.anki.provider.CardContentProvider.answerCard(SourceFile:30)
    at com.ichi2.anki.provider.CardContentProvider.update(SourceFile:43)
    at android.content.ContentProvider.update(Unknown Source:20)
    at android.content.ContentProvider$Transport.update(Unknown Source:41)
    at android.content.ContentProviderNative.onTransact(Unknown Source:612)
    at android.os.Binder.execTransactInternal(Unknown Source:103)
    at android.os.Binder.execTransact(Unknown Source:16)

net.ankiweb.rsdroid.exceptions.BackendInvalidInputException: card was modified: Normal(
    Review(
        ReviewState {
            scheduled_days: 302,
            elapsed_days: 786,
            ease_factor: 2.5,
            lapses: 0,
            leeched: false,
            memory_state: None,
        },
    ),
) Normal(
    Review(
        ReviewState {
            scheduled_days: 3,
            elapsed_days: 87,
            ease_factor: 2.5,
            lapses: 0,
            leeched: false,
            memory_state: None,
        },
    ),
)
    at net.ankiweb.rsdroid.exceptions.BackendInvalidInputException$Companion.fromInvalidInputError(SourceFile:40)
    at net.ankiweb.rsdroid.BackendException$Companion.fromError(SourceFile:105)
    at net.ankiweb.rsdroid.BackendKt.unpackResult(SourceFile:31)
    at net.ankiweb.rsdroid.BackendKt.access$unpackResult(SourceFile:1)
    at net.ankiweb.rsdroid.Backend$runMethodRaw$1.invoke(SourceFile:2)
    at net.ankiweb.rsdroid.Backend$runMethodRaw$1.invoke(SourceFile:1)
    at net.ankiweb.rsdroid.Backend.withBackend(SourceFile:8)
    at net.ankiweb.rsdroid.Backend.runMethodRaw(SourceFile:16)
    at anki.backend.GeneratedBackend.answerCardRaw(SourceFile:9)
    at anki.backend.GeneratedBackend.answerCard(SourceFile:15)
    at com.ichi2.libanki.sched.Scheduler.answerCard(SourceFile:4)
    at com.ichi2.anki.provider.CardContentProvider.answerCard(SourceFile:30)
    at com.ichi2.anki.provider.CardContentProvider.update(SourceFile:43)
    at android.content.ContentProvider.update(Unknown Source:20)
    at android.content.ContentProvider$Transport.update(Unknown Source:41)
    at android.content.ContentProviderNative.onTransact(Unknown Source:612)
    at android.os.Binder.execTransactInternal(Unknown Source:103)
    at android.os.Binder.execTransact(Unknown Source:16)
Handler (android.os.Handler) {d38aed8} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {d38aed8} sending message to a Handler on a dead thread
    at android.os.MessageQueue.enqueueMessage(Unknown Source:59)
    at android.os.Handler.enqueueMessage(Unknown Source:16)
    at android.os.Handler.sendMessageAtTime(Unknown Source:37)
    at android.os.Handler.sendMessageDelayed(Unknown Source:13)
    at android.os.Handler.post(Unknown Source:6)
    at android.widget.Toast$CallbackBinder.onToastHidden(Unknown Source:7)
    at android.app.ITransientNotificationCallback$Stub.onTransact(Unknown Source:21)
    at android.os.Binder.execTransactInternal(Unknown Source:118)
    at android.os.Binder.execTransact(Unknown Source:16)
Slow Binder: BpBinder transact took 794 ms, interface=android.content.pm.IPackageManager, code=5 oneway=false

Reopening. This error I got when reviewing a card with the API.

david-allison commented 6 months ago

@warleysr Could you update the first post & title with your findings? Thanks!

warleysr commented 5 months ago

Someone has any idea how to approach this? I have no clue how to deal with it, just keeps happening.

8d580281-0fb5-408b-bb43-f54db1285dbe

github-actions[bot] commented 2 months ago

Hello 👋, this issue has been opened for more than 3 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically