ankidroid / Anki-Android

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

Add support for the new Scheduler v2 from Anki 2.1 #4905

Closed Alphyn-gunner closed 5 years ago

Alphyn-gunner commented 6 years ago
Research

[ 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


I'm posting this issue because Anki 2.1 RC1 is released and I'm worried about the compatibility between the desktop version and Ankidroid once the stable 2.1 is out. I'm sorry if it is still too early to post this issue.

Anki 2.1 stable is now released.

The 2 most notable changes in the new scheduler are:

Switching to the new scheduler in the desktop version breaks the compatibility of the collection with Ankidroid. Damien added the support of the new scheduler to Ankiweb and Ankimobile after he introduced it to the desktop beta.

From my (layman) point of view, the following steps need to be taken:

  1. Basic support for the synced collections with the new scheduler enabled in the desktop version.
  2. Ability to switch between the versions of the sheduler right in Ankidroid.

The changes the new scheduler introduces create a lot of opportunities for the more creative and efficient use of the filtered decks and subdecks. I think many Anki users will agree with me that it would be great to see those new features supported in Ankidroid as well.

Edit: here's the article with a more in-depth description of the new scheduler.

Thank you!

mikehardy commented 6 years ago

Some notes as I look through the code:

Not sure what kind of implementation plan would fly here (and I'm certainly not saying I have time to do it) but the original scheduler port was pretty straight between from Python to Java, perhaps this one can be as well. The ability to go back and forth between the two (even though it is difficult and involves all sorts of gates on package import/export and synchronization) seems like a good idea given Anki is a distributed system.

mikehardy commented 6 years ago

This is obviously popular - I just want to note that even the primary Anki developer has mentioned that it is involved and we should tackle the other 2.1 items first.

Other than that, the original scheduler port was as straightforward as it could be made from Python to Java, if someone wanted to look at schedv2.py and start the process, PRs would be welcome!

mnhende2 commented 6 years ago

Mike, Thanks for all you, Tim and any others do in developing AnkiDroid. Always much appreciated! While many of us look forward to the new scheduler being incorporated, we know that the AnkiDroid team is constantly working on a number of other important upgrades or bug fixes also. So, just a note of thanks for all the great work done and a future note of thanks for when the new scheduler and other features are incorporated as possible. Best, mnhende2

penguingiraffe2 commented 5 years ago

Has anyone found a workaround for this which allows for offline studying on Android? I have not touched AnkiDroid since using v2 scheduler for fear of messing up card schedules. The anki online website is an option but the interface leaves something to be desired...

mikehardy commented 5 years ago

AnkiDroid is the only Anki client on Android I know of, and it doesn't support v2 scheduler yet, so if you want offline study, you either need to stick to (or convert back to - it's possible) v1 scheduler, or make a PR here for V2 scheduler support (which would be awesome, by the way ;-) )

penguingiraffe2 commented 5 years ago

Aw thanks for the reply @mikehardy, I have rudimentary python training and your notes above go over my head, so I fear my PR would just be worthless 🙈

mikehardy commented 5 years ago

I will mention I have looked at the code for transitioning between v1 and v2 scheduler in AnkiDesktop and it looks sane to me. If someone wanted to try going from v2 scheduler to v1 and report here how it works, at least people that see this issue will know what they need to do in order to use AnkiDroid until this is solved

FatCache commented 5 years ago

This is obviously popular - I just want to note that even the primary Anki developer has mentioned that it is involved and we should tackle the other 2.1 items first.

Other than that, the original scheduler port was as straightforward as it could be made from Python to Java, if someone wanted to look at schedv2.py and start the process, PRs would be welcome!

For confirmation sake to see if I am looking at this problem correctly, is the Java port of sched.py to be this Sched.java

Any 'difference' pointer will be appreciated. My approach is to smply compare the two files sched.py & schedv2.py, side by side for differences/improvements.

mikehardy commented 5 years ago

That is correct and it is the first step to implementing the feature, also looking at the v1 differences (maybe with github history) to see the original two python and Java files to see how it was done the first time

ChrisPWill commented 5 years ago

Hi guys, I've gone through scheduler v2 in the Python codebase and replicated each difference in a new SchedV2 class in #5164. I've had exposure to Java in the past but haven't done Android development much in the past so I'm open to any feedback. All in all, I'm prepared to assist with testing and integration of the new scheduler into the rest of the app if needed.

timrae commented 5 years ago

Thanks for your work on this!

Alphyn-gunner commented 5 years ago

A heads up for anyone who stumbled upon this issue looking for a temporary workaround.

There's a family of add-ons that make it possible to enjoy some benefits of the new scheduler on PC, while you continue to use the legacy scheduler in order to retain the compatibility with AnkiDroid.

HoochieMama: Randomize Rev Queue HoochiePapa: Randomize New Queue HoochieBaby: Queue Controller & Day-Learning Queue

Of course, those add-ons will only work while you do your reviews on the desktop version of Anki. On your android device, you will have to do the reviews the old way, on a deck per deck basis. But, at least you’ll be able to sync your collection.

mikehardy commented 5 years ago

If anyone wants to test @hssm 's work, I've attached a version here: https://github.com/ankidroid/Anki-Android/pull/5214#issuecomment-459969405

Should be noted that if you install the debug version you'll have to uninstall it afterwards and re-install from the Play Store most likely, to begin receiving normal updates again. But this issue has some very motivated people I think, so maybe someone could look at it...

Alphyn-gunner commented 5 years ago

Thank you, Mike, @hssm and everyone else who is working on this! What is a better place for feedback, this thread or #5214?

I haven't been able to install the apk, though. I tested it on a Android 8 AOSP phone and an Anroid 6 MIUI 9.5 phone. I get the "Application is not installed" error. I deleted any previous installations of Anki and removed the Ankidroid folder.

mikehardy commented 5 years ago

Hmm - I will defer to @hssm about where to leave feedback, he who implements gets to decide most things ;-). With regard to not being able to install it to test, that's a bummer - it was the first time I'd tried to toss up just a "debug" APK built from AndroidStudio and maybe that didn't work well for some reason. I'll try again but with one of the "parallel" releases (the .A, .B etc builds) I make and maybe that will go better.

timrae commented 5 years ago

Is there anyone who would be willing to port over the unit tests from python to Java for us? This would be the best way to ensure that this feature gets released quickly.

hssm commented 5 years ago

Please use this thread to report any issues you find. I don't receive notifications so I won't look at PRs after they are merged.

I've made progress on adding a version toggle in AnkiDroid, so the only task remaining is the exporting changes. I will get to that next weekend, hopefully.

Alphyn-gunner commented 5 years ago

It's a minor thing, but I just noticed that the stats screen for buttons preseed still shows 3 buttons for new/learning cards, even though there's now a Hard button.

slesniak commented 5 years ago

I am using Anki 2.9alpha61 and when doing reviews on mobile, good and easy show the same interval every time (for reviews, non-lapsed). This is different than the behavior I see on Anki 2.1.8 desktop.

My max interval is the default (36,500 days) and much longer than any of my cards (max 2.8 years) so that's not the issue.

If this comment should be made somewhere else, let me know

Alphyn-gunner commented 5 years ago

Can confirm, I have the same issue with alpha 61. Ankidroid.E build also has this.

I've tested it some more, and some cards have this issue, while others don't. I couldn't determine what sets them apart. It's not deck or note type. Maybe, cards that were new when the new scheduler was enabled vs cards that were already due, or something like that. But it's just a guess.

hssm commented 5 years ago

Thanks for reporting the issue. I've pushed a fix for it to https://github.com/ankidroid/Anki-Android/pull/5219

timrae commented 5 years ago

Did you see #5229?

hssm commented 5 years ago

I did not. I've just pushed a fix for that too.

twwn commented 5 years ago

Are you sure you pushed? There seem no new commits/pull requests.

hssm commented 5 years ago

The PR was already merged by that point so it didn't show up. I've just opened a new PR that completes the rest of the work and brings it in line with the desktop client (including the stats issue mentioned above).

A very important note to anyone who is already using the v2 scheduler: the official instructions for these changes (2.1.9beta1) advise you to switch back to the v1 scheduler, update, then switch back to v2. (If you've only used AnkiDroid then there is no need to do this since the bug was never present). From this point on, switching between v1 and v2 and back will have irreversible side-effects to your revision history. I'm not sure if this behavior will remain in the final version, but that's how it works now so be mindful of it before testing on your day-to-day collection. Fixed now.

Another side-note: I encountered a bug which I haven't been able to reproduce yet when burying a large number of cards where I got reviews of really easy cards with massive negative intervals (like -18 years). I'm not yet sure if this is a scheduler or AnkiDroid bug, but be aware of this potentially affecting you as well.

Alphyn-gunner commented 5 years ago

switch back to the v1 scheduler, update, then switch back to v2

Does this include updating Ankidroid?

mikehardy commented 5 years ago

From this point on, switching between v1 and v2 and back will have irreversible side-effects to your revision history

Am I correct in my read of the diff that the revision history is to switch the ease assigned to certain revisions? I ask because it seemed like it moved them in a very predictable way, and rather than the drastic-but-vague "irreversible side-effects to your revision history", we could specify exactly what happens as a result of these:

2->1 https://github.com/ankidroid/Anki-Android/pull/5232/files#diff-7f010620d726ffe711b87a36f86ae4fbR2578

1->2 https://github.com/ankidroid/Anki-Android/pull/5232/files#diff-7f010620d726ffe711b87a36f86ae4fbR2585

hssm commented 5 years ago

Sorry I should have been more clear.

@dae You might want to be aware of this. Re: scheduler switching and revlog rewriting, I believe it needs to be restricted to queue type 0 (and 2?).

Right now going to V1 erases ("conflates") your 4's and back to V2 erases your 2's for every queue type

v2 -> v1 -> v2
1  -> 1  -> 1
2  -> 2  -> 3
3  -> 2  -> 3
4  -> 3  -> 4

V2->V1 image V1->v2 image

dae commented 5 years ago

Thanks for letting me know, I'm not sure how I missed that. I've pulled the beta, rushed out an update to git, and posted a warning on the beta page that people will need to restore from backup. I should have beta2 out tomorrow with the fix:

https://anki.tenderapp.com/discussions/beta-testing/1381-anki-219-beta

Are you able to confirm the current git code behaves as expected when changing the scheduler on your collection?

hssm commented 5 years ago

Yes it looks like it's fine now.

slesniak commented 5 years ago

Just for clarification, do I need to do the steps in https://github.com/ankidroid/Anki-Android/issues/4905#issuecomment-462157839 if I'm using the stable desktop release (2.1.8)? Is the latest alpha release of Ankidroid compatible with 2.1.8?

I've held off doing any studying on my phone pending clarification.

dae commented 5 years ago

2.1.8 doesn't make such a change when switching schedulers. If you don't plan on testing the desktop betas, once 2.1.9 is released I'd suggest turning the v2 scheduler off in 2.1.8, then turning it back on using 2.1.9.

mikehardy commented 5 years ago

5235 appears to show a v2 related review count hierarchy error

mikehardy commented 5 years ago

Is this closable? I think it is...

mikehardy commented 5 years ago

People that want to use this should follow the procedure to have Google Play start installing the latest alphas: https://github.com/ankidroid/Anki-Android/wiki/Installation#beta--alpha-releases

AustinHasten commented 5 years ago

Seems to be playing nicely with the latest alpha, at least as far as I can tell. I did notice, however, that it is not possible to see (or therefore edit) the second search on a filtered deck (as 2 are supported under the new scheduler rather than 1). I intend to test whether the second search does still apply when rebuilding filtered decks via the app. Does this fall under "Add support for the new Scheduler v2 from Anki 2.1" or would another issue be raised after this is closed?

mikehardy commented 5 years ago

@AustinHasten nice to hear it seems like it's working for you, modulo the 2nd search issue you mention. My preference is always separate issues for new things but in this specific case I believe @hssm (who did all the heavy lifting here) is careful with notifications and was only listening in on one thread, so I'm tagging him specifically and it's up to him. If he doesn't have time though, new issue is my pref

hssm commented 5 years ago

I won't have time to look into it anytime soon, so I think close this one and open a new issue.

mikehardy commented 5 years ago

I'm going to close this so I can maintain this as the last comment. It seems to be working for everyone. Please open new issues if something goes wrong, or if there is something remaining here that is unaddressed.

For people that land here because "your anki client is not compatible with the v2 scheduler", you need to install the latest alphas of AnkiDroid, and you'll be set: https://github.com/ankidroid/Anki-Android/wiki/Installation#beta--alpha-releases