ijgnd / anki__preview_card_edit_note_in_extra_window_linked_from_reviewer

0 stars 1 forks source link

Breaks browser in Anki 2.1.44 #11

Closed ambimorph closed 3 years ago

ambimorph commented 3 years ago

Debug info: Anki 2.1.44 (b2b3275f) 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-06-28 11:20:47

Caught exception: Traceback (most recent call last): File "aqt/webview.py", line 36, in cmd File "aqt/webview.py", line 135, in _onCmd File "aqt/webview.py", line 580, in _onBridgeCmd File "aqt/toolbar.py", line 169, in _linkHandler File "aqt/toolbar.py", line 187, in _browseLinkHandler File "aqt/main.py", line 1067, in onBrowse File "aqt/init.py", line 101, in open TypeError: init() got an unexpected keyword argument 'card'

ijgnd commented 3 years ago

I don't get this error in 2.1.44 at the moment.

I had some similar bug reports. For some people it was different add-ons (see e.g. here) and for some people this only occured with my add-on after updating anki. For some of the latter cases updating the add-ons helped, others said that reinstalling my add-on fixed the problem.

Does this problem still occur in Anki 2.1.44 if you have disabled all other add-ons, have reinstalled this add-on and restarted Anki? If so that's unfortunate. Then I'll try to look into this in depth when I have more time (unfortunately in about two weeks at the earliest). Does this problem only occur under special cases or always when you try to open the browser?

Thanks for your help.

ambimorph commented 3 years ago

I will test disabling all other add-ons and reinstalling and let you know. At the moment I think it is always and only when I try to open the browser.

I love your work. I hope it turns out to be an easy fix!

ambimorph commented 3 years ago

Ok. Confirmed that it still occurs when every other add-on is disabled and even after a reinstall. I restarted Anki between every test.

ijgnd commented 3 years ago

That's really strange and bothered me so I looked into it just now. But I still don't understand how my add-on could cause this.

The error message shouldn't depend on platform-specific code so the error should be reproducible. But I don't get such an error if I run 2.1.44 with all my usual add-ons or just this one add-on, neither in Windows nor in Linux.

2.1.44 is virtually the same as 2.1.43 and 2.1.43 was released in 2021-04-03. Since then I have not gotten any error reports that my add-on would cause such a bug. Admittedly very few people use my add-on and not everyone reports problem but I guess I should have seen at least one downvote etc. (?)

 

I also don't understand how my add-on could cause it:

The lines from your error message

File "aqt/toolbar.py", line 169, in _linkHandler
File "aqt/toolbar.py", line 187, in _browseLinkHandler

indicate that you've clicked the word "Browser" in the top bar of the main window (between "Add" and "Stats").

The line File "aqt/main.py", line 1067, in onBrowse is about this method which calls Anki's profile manager from aqt/init.py.

The lines

File "aqt/init.py", line 101, in open
TypeError: init() got an unexpected keyword argument 'card'

indicate that the __init__ method of the Browser class got the wrong arguments. My add-on does not modify the __init__ method of the browser class. Instead my changes to the browser only use the new style hook system from anki so that my code that modifes the anki browser is called from within the Browser class which means that my code should not be able to break the __init__ method of it, see my browser.py file.

There's one popular add-on that overwrites the __init__ method of the browser, i.e. the Advanced Browser. Actually a similar error was caused by an older versions of Advanced Browser, see here which was fixed here.

 

I just saw your zettelkasten+anki repo. That looks very interesting. Since you've done some anki related coding and your python code is much better than mine I think you'll have a better chance than me to figure this out. I have no more ideas at the moment. Any help is welcome.

ambimorph commented 3 years ago

Thank you for looking into it! I agree it's strange.

I do normally use the Advanced Browser, but it was disabled. I'll take a look and see if I can figure out if it' somehow still interfering, or anything else.

ambimorph commented 3 years ago

Ok, ijgnd. I haven't even opened your code yet, but coincidentally, I just now got an upgrade notice to Advanced Browser and after the upgrade, your add-on works again.

This is perplexing for at least two reasons. First, that add-on was disabled, so I don't see how it could affect things! Second, there doesn't appear to be a change in the Advanced Browser code since February (the one you mentioned above). So why would I only get it now? I don't know, but in any case, this is obviously not a problem with your code, and I'm very happy I can use it again.

Thanks again for checking into it. Sorry to take up your time.

ijgnd commented 3 years ago
ambimorph commented 3 years ago

Re: disabling add-ons and restarting, I know about that. That's exactly what I did. After any change to an add-on, I always restart before considering it actually enabled/disabled. When I said Advanced Browser was "disabled", I meant I actually disabled it, by toggling enable so it says disable, and then restarting. After disabling Advanced Browser (including restarting!) I was still getting this error. Until I updated Advanced Browser, the only way to get rid of the error was to disable this add-on here. I still don't understand how a different add-on that's disabled (including a restart) could have a persistent effect on your add-on.

Assuming Advanced Browser was the latest version was a mistake I didn't know I was making, though. Often when I restart Anki, it will tell me about new add-on versions, so I assumed everything was latest.

ijgnd commented 3 years ago

Thanks for the update.

I still don't understand how a different add-on that's disabled (including a restart) could have a persistent effect on your add-on.

me neither. I hoped to have an explanation. Now it's back to strange again. If you see a reason in the addon.py code let me know ...

Now if there's a strange error I'll tell people to try by deleting moving the addons21 folder (so that one can later easily get back all the add-ons with ones settings).