Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

[Bug] An error will be triggered when rating a card while the AnkiDroidJS API is processing `api.ankiSetCardDue()`

Open ChuckieChen945 opened this issue 1 year ago • 5 comments

Reproduction Steps

I can’t reproduce this error because the timing of triggering is very important. But I have some clues about this Bug and a video of triggering this Bug:

I have a deck for practicing English listening. The script in the card template is set to: automatically display the answer, play the audio on the back of the card twice, and then execute api.ankiSetCardDue(0), Set the card’s due date to today (this can achieve the effect of looping the audio in the deck: you can listen to the audio in the entire deck while doing housework and other free time, you don’t have to rate a single card immediately, and you won’t get stuck on a card; if I can free my hands, I will rate the card that is playing). When the audio playback ends, if I happen to press the rate button when AnkiDroid executes api.ankiSetCardDue(0), an error will occur. See the video below:

https://github.com/ankidroid/Anki-Android/assets/29732324/5b599136-f5ad-4d0b-a5e0-0dfb16d57913

(The error is at the 30th second in the video. I have undone the answer card several times in the video, but I think this should not affect it.)

Depending on the timing of the trigger, sometimes it is “not at top of queue” (see the above video), sometimes it is “card was modified” (see the picture below, and “card was modified” is triggered more frequently), this may be related to the internal processing steps of api.ankiSetCardDue() (I'm not sure).

Screenshot_20240314_155312_com ichi2 anki

The timing of the trigger is very important, so it is difficult to deliberately manually trigger. I have tried to execute api.ankiSetCardDue(0) and buttonAnswerEase3() in the card template in sequence, but I have not been able to trigger this error. Perhaps rating through the AnkiDroidJS API and manual rating have different mechanisms(I'm not sure). Checking the source code to see if it can correctly handle the situation where the user rates the card during the execution of api.ankiSetCardDue() may get further information about this Bug.

Expected Result

Correctly handle the situation where the user manually rates the card while the program is executing api.ankiSetCardDue().

Actual Result

Throw “not at top of queue” or “card was modified”.

Debug info
AnkiDroid Version = 2.17.5 (1c1aa94ec466f37d33fd2f75020d9f9021ac811e)

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

Android Version = 10 (SDK 29)

ProductFlavor = full

Manufacturer = HUAWEI

Model = MXW-AN00

Hardware = mt6873

Webview User Agent = Mozilla/5.0 (Linux; Android 10; MXW-AN00 Build/HONORMXW-AN00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/92.0.4515.105 Mobile Safari/537.36

ACRA UUID = 82400b65-bd87-4883-a1f6-b911150f725b

Crash Reports Enabled = true
Research

Enter an [x] character to confirm the points below:

  • [x] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
  • [x] I have checked the manual and the FAQ and could not find a solution to my issue
  • [x] I have searched for similar existing issues here and on the user forum
  • [X] (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)

ChuckieChen945 avatar Mar 19 '24 11:03 ChuckieChen945

I will investigate the issue.

krmanik avatar Mar 19 '24 13:03 krmanik

@ChuckieChen945 Can you share the deck here?, if it is private deck then you can email it me [email protected].

krmanik avatar Apr 19 '24 04:04 krmanik

@ChuckieChen945 Can you share the deck here?, if it is private deck then you can email it me [email protected].

This is indeed my private deck. I have sent it to [email protected], with the email subject as “AnkiDroid issues 15936 related deck”. I apologize for not attaching the relevant deck at the first time as I thought this was a relatively easy issue to solve. To better demonstrate this issue, I recorded a few unedited videos. By the way, this time I used AnkiDroid 2.18alpha8 and AnkiDroidJS API 0.0.3. This issue still exists in the latest alpha release. In the following videos, I am not really studying Anki cards, but just trying to trigger this issue as efficiently as possible, so I set the audio speed very fast and only play it once.

https://github.com/ankidroid/Anki-Android/assets/29732324/9a47ae25-13f5-4843-bbb0-05a41cde724a

In this video, this issue is triggered at the 60th second. Turning on the slide switch in the lower right corner of the card will fix the current card, which is no different from the general use of Anki; turning off the slide switch in the lower right corner of the card will execute api.ankiSetCardDue(0) after the audio in each card is played, so it can achieve the effect of looping the audio in the deck.

https://github.com/ankidroid/Anki-Android/assets/29732324/0e4c7d77-633a-49ff-a6d6-3b0c4e7a67e2

In this video, this issue is triggered at 1 minute and 36 seconds.

https://github.com/ankidroid/Anki-Android/assets/29732324/411543ba-76f2-4427-87fa-f368d58433b0

In this video, this issue is triggered at the 30th second.

I also know that this issue is currently difficult to be triggered stably, so if you need more information, you can contact me at any time.

ChuckieChen945 avatar Apr 19 '24 12:04 ChuckieChen945

I have got the mail, I will debug comment info here.

krmanik avatar Apr 19 '24 12:04 krmanik

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

github-actions[bot] avatar Sep 03 '24 07:09 github-actions[bot]