-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove legacy collection loading code from AnkiFragment #17457
Remove legacy collection loading code from AnkiFragment #17457
Conversation
This class was using the legacy CollectionLoader to return the already available for use, CollectionManager.getColUnsafe(). The try-catch replicates CollectionLoader's behavior which invokes the activity's onCollectionLoadError() method to go to DeckPicker when faced with any exception during loading the collection. Probably fixes ankidroid#17380 where a NullPointerException is thrown for one of AnkiFragment's subclasses, NoteEditor, because the culprit property editorNote is assigned a valid note in the callback onCollectionLoaded() which may or may not be executed at the right time.
@criticalAY I made this PR although you were assigned because I don't think the bug is related to multimedia stuff. |
Cool cool, that was not related to multimedia anyway thanks for taking some weight off ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, and I like this as a pick to 2.19 to hopefully address some of the Poison::unwrap issues there as the hypothesis is that it is getColUnsafe and racy code as a root cause
But I want a second set of eyes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM.
Could someone test a 'clean open' of this screen from the 'Anki Card' context menu shortcut before merging.
On it re: the testing request |
Worked fine, going to merge etc test: Seems good anki-card-context-menu-clean-open.webmWow, should have made that lower resolution / quality, sorry. Quite a big file. |
Purpose / Description
AnkiFragment was using CollectionManager.getColUnsafe() and also set up a loading mechanism similar with the CollectionLoader used by AnkiActivity returning the same CollectionManager.getColUnsafe(). This PR removes the loading mechanism and lets NoteEditor to only use CollectionManager.getColUnsafe(). This way, the setup that was done in onCollectionLoaded() is inserted in the fragment lifecycle and should prevent bugs from the bad timing around onCollectionLoaded().
The progress bar in the layout was removed because it was only used for the collection loading mechanism.
I was kind of able to reproduce the error in #17380 by using the same steps from #17407(modify the collection loading in ANkiFragment) and opening NoteEditor -> attach image. I said kind of because there's a bug in the multimedia image selection(see #17455) where the return to NoteEditor doesn't work quite right with Don't keep activities enabled. IMO both bugs in #17380 and #17407 are happening because there's bad timing between the code expecting the collection to be available and the collection not being yet available( meaning onCollectionLoaded() executed).
At reviewers discretion if this should go in 2.19.x.
Fixes
NoteEditor.getCurrentMultimediaEditableNote
: NullPointerException #17380How Has This Been Tested?
Tried to add things, ran the tests.
Checklist