glutanimate / review-heatmap

Anki add-on to help you keep track of your review activity
https://ankiweb.net/shared/info/1771074083
Other
1.2k stars 88 forks source link

Anki shows error when clicking on a deck to study #153

Closed rafaelcdepaula closed 2 years ago

rafaelcdepaula commented 2 years ago

Problem description

Sometimes, choosing a deck to study shows an error on the screen. It doesn't happen all the times.

Checklist

Information about your Anki set-up


    Anki 2.1.52 (ab1c2395) Python 3.9.10 Qt 6.3.0 PyQt 6.3.0
    Platform: Linux
    Flags: frz=True ao=True sv=2
    Add-ons, last update check: 2022-05-21 12:58:41

    ===Add-ons (active)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    Cloze Hide All ['1709973686', 2021-09-11T07:00, '21.9.11i107', mod]
    Edit Field During Review ['1020366288', 2020-10-07T09:22, 'None', '']
    Image Occlusion Enhanced for Anki 21 ['1374772155', 2022-04-09T04:15, 'None', '']
    Large and Colorful Buttons ['1829090218', 2018-10-02T14:41, 'None', '']
    Review Heatmap ['1771074083', 2022-05-18T12:53, 'None', '']

    ===IDs of active AnkiWeb add-ons===
    1020366288 1374772155 1709973686 1771074083 1829090218

    ===Add-ons (inactive)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    Custom Background Image and Gear Icon ['1210908941', 2022-04-10T12:30, 'None', mod]

Error message (if any)

Caught exception:
Traceback (most recent call last):
  File "aqt.taskman", line 122, in _on_closures_pending
  File "aqt.taskman", line 71, in <lambda>
  File "aqt.taskman", line 90, in wrapped_done
  File "aqt.operations", line 125, in wrapped_done
  File "aqt.deckbrowser", line 124, in <lambda>
  File "aqt.main", line 1143, in onOverview
  File "aqt.main", line 672, in moveToState
  File "aqt.main", line 690, in _overviewState
  File "aqt.overview", line 61, in show
  File "aqt.overview", line 66, in refresh
  File "aqt.overview", line 194, in _renderPage
  File "aqt.hooks_gen", line 3142, in __call__
  File "/home/rafael/.local/share/Anki2/addons21/1771074083/views.py", line 112, in overview_will_render_content
    heatmap_html = self._controller.render_for_view(
  File "/home/rafael/.local/share/Anki2/addons21/1771074083/controller.py", line 77, in render_for_view
    return self._renderer.render(view, limhist, limfcst, current_deck_only)
  File "/home/rafael/.local/share/Anki2/addons21/1771074083/renderer.py", line 152, in render
    report = self._reporter.get_report(
  File "/home/rafael/.local/share/Anki2/addons21/1771074083/activity.py", line 134, in get_report
    history = self._cards_done(
  File "/home/rafael/.local/share/Anki2/addons21/1771074083/activity.py", line 471, in _cards_done
    deck_limit = self._revlog_limit(current_deck_only)
  File "/home/rafael/.local/share/Anki2/addons21/1771074083/activity.py", line 383, in _revlog_limit
    dids = self._col.decks.active()
  File "anki.decks", line 413, in active
  File "anki._legacy", line 78, in __getattr__
AttributeError: 'Scheduler' object has no attribute 'active_decks'
glutanimate commented 2 years ago

Thanks for the detailed report @rafaelcdepaula, it's much appreciated. I haven't had any luck reproducing this yet, but it seems like it could be an upstream issue with Anki.

@dae do you have any idea what could be causing this? Looking through the code of all three schedulers, I can't think of any scenario that would cause the active_decks prop to not be accessible. The only other reference to this I found is from back around 2.1.45's release: https://forums.ankiweb.net/t/anki-2-1-45-alpha/10061/26?u=glutanimate

glutanimate commented 2 years ago

@rafaelcdepaula I've pushed a workaround that should hopefully address this for now. Would you mind giving the latest development build a try and letting me know if it works for you?

glutanimate commented 2 years ago

Quick heads-up: I've updated the link to the build as the previous one wasn't built correctly.

dae commented 2 years ago

Not sure what's going on there.

rafaelcdepaula commented 2 years ago

@rafaelcdepaula I've pushed a workaround that should hopefully address this for now. Would you mind giving the latest development build a try and letting me know if it works for you?

@glutanimate I've tested a few times and it seems to work perfectly. Thank you for your help.

glutanimate commented 2 years ago

@dae thanks for taking a look! I'm really puzzled by this one as well, thus the pre-emptive workaround as it seemed easier than trying to understand what's going on. Will still see if I can dig further into this.

@rafaelcdepaula cheers for giving it a try! Glad to hear the workaround works. If you have time, just a couple more questions to perhaps get closer to drilling down to the underlying cause:

  1. When you had this issue, how frequently would the error message pop up? Was it a once-in-a-blue-moon type occurrence or would it reliably appear multiple times per session?
  2. Looking at the Anki debug info, I do see that you also had other add-ons active (at the time). None of them really seem like they could be factoring into this (and installing them locally I was not able to reproduce the problem either), but I assume you did try to disable them and were still experiencing the same problem?

Thanks again

glutanimate commented 2 years ago

(merged the workaround for now, but would ideally still like to get to the bottom of this)

rafaelcdepaula commented 2 years ago

@glutanimate:

When you had this issue, how frequently would the error message pop up? Was it a once-in-a-blue-moon type occurrence or would it reliably appear multiple times per session?

Now I know how to reproduce the steps to get the error (at least for me): Obs.: I have 2 profiles in Anki, one to study, and other for tests (cards templates, add-ons, etc.)

  1. Start Anki opening the main profile.
  2. Switch to the other profile.
  3. Click on a deck (with at least one card) with no activity. The error will appear.

Just noticed it stops showing the reviews for all decks. image

Looking at the Anki debug info, I do see that you also had other add-ons active (at the time). None of them really seem like they could be factoring into this (and installing them locally I was not able to reproduce the problem either), but I assume you did try to disable them and were still experiencing the same problem?

Yes, even when all the other add-ons are disabled the error still shows up.

glutanimate commented 2 years ago

@rafaelcdepaula thanks for investigating this further, that was super helpful! I think I've got a fairly good (though not 100%) grasp of what could be going on here now. Tracking the likely proper fix in #159.