ThoreBor / Anki_Leaderboard

Anki 2.1 Add-On
https://ankiweb.net/shared/info/41708974
MIT License
52 stars 11 forks source link

Index out of range in on_deck_browser_will_render_content #152

Closed luaneko closed 3 years ago

luaneko commented 3 years ago

Describe the bug Index out of range exception in progress.py when leaderboard in home screen is enabled.

Steps to reproduce bug I'm really not sure. This error did not occur when I installed this addon yesterday. It started happening the next morning (the day of this report).

This does not happen when the leaderboard is opened manually with Shift+L. It can be reproduced consistently when synchronizing the leaderboard in home screen with Shift+S.

Info

Addon config:

image

Additional context

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.46 (94913ec2) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Mac 10.16
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-08-26 11:13:04
Add-ons possibly involved: ⁨Leaderboard⁩

Caught exception:
Traceback (most recent call last):
  File "aqt/progress.py", line 54, in handler
  File "aqt/main.py", line 150, in on_window_init
  File "aqt/main.py", line 245, in setupProfile
  File "aqt/main.py", line 425, in loadProfile
  File "aqt/hooks_gen.py", line 2907, in __call__
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/__init__.py", line 126, in profileHook
    leaderboard_on_deck_browser()
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/lb_on_homescreen.py", line 258, in leaderboard_on_deck_browser
    DB.refresh()
  File "aqt/deckbrowser.py", line 74, in refresh
  File "aqt/deckbrowser.py", line 143, in _renderPage
  File "aqt/deckbrowser.py", line 152, in __renderPage
  File "aqt/hooks_gen.py", line 1275, in __call__
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/lb_on_homescreen.py", line 132, in on_deck_browser_will_render_content
    result.append(lb[i])
IndexError: list index out of range
ThoreBor commented 3 years ago

Thanks for letting me know. I'll look into it. Do you still get the error after restarting Anki?

luaneko commented 3 years ago

I disabled the addon until your response, and after enabling it and restarting Anki, I cannot reproduce this bug anymore. That's annoying.

What's even more strange is that I was able to reproduce this bug consistently across restarts, before I had disabled the addon.

The bug does not occur regardless of whether Focus user setting is toggled. I didn't confirm its effect while the bug was still present.

I think we need more input from @Dreadeyee (the other issue creator) since this bug is unreproducible on my side now.

Dreadeyee commented 3 years ago

I tried disabling before posting and it did not work for me idk why. I am leaving this screenshot of my settings if this helps. Feel free to quote me if you need anything more specific. Noted now it seems to work fine for no apparent reason Screenshot 2021-08-26 at 13 59 56

luaneko commented 3 years ago

This bug is most definitely related to time, the number of reviews or some weird external factor, because it's occurring again for me. It's 08:35 right now and having done no reviews yet, I can consistently reproduce this error:

This is the error when starting Anki:

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.46 (94913ec2) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Mac 10.16
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-08-26 11:13:04
Add-ons possibly involved: ⁨Leaderboard⁩

Caught exception:
Traceback (most recent call last):
  File "aqt/progress.py", line 54, in handler
  File "aqt/main.py", line 150, in on_window_init
  File "aqt/main.py", line 245, in setupProfile
  File "aqt/main.py", line 425, in loadProfile
  File "aqt/hooks_gen.py", line 2907, in __call__
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/__init__.py", line 126, in profileHook
    leaderboard_on_deck_browser()
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/lb_on_homescreen.py", line 258, in leaderboard_on_deck_browser
    DB.refresh()
  File "aqt/deckbrowser.py", line 74, in refresh
  File "aqt/deckbrowser.py", line 143, in _renderPage
  File "aqt/deckbrowser.py", line 152, in __renderPage
  File "aqt/hooks_gen.py", line 1275, in __call__
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/lb_on_homescreen.py", line 132, in on_deck_browser_will_render_content
    result.append(lb[i])
IndexError: list index out of range

This is the error when synchronizing:

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.46 (94913ec2) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Mac 10.16
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-08-26 11:13:04
Add-ons possibly involved: ⁨Leaderboard⁩

Caught exception:
Traceback (most recent call last):
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/__init__.py", line 100, in background_sync
    leaderboard_on_deck_browser()
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/lb_on_homescreen.py", line 258, in leaderboard_on_deck_browser
    DB.refresh()
  File "aqt/deckbrowser.py", line 74, in refresh
  File "aqt/deckbrowser.py", line 143, in _renderPage
  File "aqt/deckbrowser.py", line 152, in __renderPage
  File "aqt/hooks_gen.py", line 1275, in __call__
  File "/Users/phosphene47/Library/Application Support/Anki2/addons21/41708974/lb_on_homescreen.py", line 132, in on_deck_browser_will_render_content
    result.append(lb[i])
IndexError: list index out of range

It is still occurring after having done 10 reviews. It does not occur in the main leaderboard window.


Similar to #153, this bug does not occur when Focus on user setting is disabled.

image
ThoreBor commented 3 years ago

Okay, thanks. If you get this error again, could you send me your meta.json file? You can find it by going to Tools>Add-ons>Leaderboard>View files. If you can find it, just send me the homescreen_data list in the file. Otherwise please send the entire file to leaderboard_support@protonmail.com (because your leaderboard authentication token is in there as well and that shouldn't be public).

ThoreBor commented 3 years ago

Never mind, I was able to reproduce the error. If there are not maximum number of users on homescreen Leaderboard / 2 after you you'll get the error. Could you guys confirm that that's the issue?

luaneko commented 3 years ago

Could you guys confirm that that's the issue?

I would assume that to be the case. At the time of writing this comment, the global leaderboard has enough users that this error isn't occurring anymore. However when I switch the default to country leaderboard, which presumably has less users than the global version, the error can be reproduced.

Dreadeyee commented 3 years ago

I think that would be valid. The global leaderboard currently has 42 users and the bug is reproducible even after disabling/enabling/restarting.