Skip to content
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

Conversion blocks AnkiConnect from adding more cards until conversion is done #31

Open
kanjieater opened this issue Jun 13, 2024 · 6 comments

Comments

@kanjieater
Copy link

kanjieater commented Jun 13, 2024

Sometimes I take full window screenshots at 1440p and add them via Rikaitan. I noticed that when the add-on is enabled it does a great job shrinking the screenshots down to reasonable file storage sizes, but if I'm not mistaken, seems to be blocking the server from any further card creation until it's done.

Is there any way the adding of a card via Rikaitan/ankiconnect and applying the image transformations could be done in a way that doesn't tie up the server or prevent users from adding multiple cards while the work is being done?

tatsumoto-ren added a commit that referenced this issue Jun 13, 2024
@tatsumoto-ren
Copy link
Member

Sorry, had to update your comment because it mentioned untrusted software. The Ankiconnect server? Apparently it has to wait until conversion is finished. But I don't think it runs long enough to interrupt mining with Rikaitan unless you create cards literally every second.

@tatsumoto-ren
Copy link
Member

Anki provides the editor_will_process_mime hook that addons can use to edit whatever is being pasted. It takes mime data and returns mime data. Because the add-on has to return something, it blocks.

When a new note is added through ankiconnect, it has no ID yet, so the add-on edits it before the note_will_be_added hook returns.

An alternative would be to return immediately, then process the image in a separate thread, then search the Anki collection to find the new note, then replace image references and update the note.

@kanjieater
Copy link
Author

Sorry, had to update your comment because it mentioned untrusted software. The Ankiconnect server? Apparently it has to wait until conversion is finished. But I don't think it runs long enough to interrupt mining with Rikaitan unless you create cards literally every second.

Unfortunatley, for large images, it can take multiple seconds. If there are more than one words to mine in a phrase, I find myself waiting for 5-10s waiting for the image to process. I have a very 13th gen i9, so I imagine users with slower CPU's or 4k displays see this number increase even higher.

Given that it relies on the clipboard, you also don't want to read the next line of whatever you're consuming, given that advancing will clear whatever image is on your clipboard.

I would think a seamless process like the one you described that doesn't block the users actions would be ideal:

An alternative would be to return immediately, then process the image in a separate thread, then search the Anki collection to find the new note, then replace image references and update the note.

@tatsumoto-ren
Copy link
Member

tatsumoto-ren commented Jun 13, 2024

Yeah I imagine this will be fine.

Okay so if you want to work on this issue I can assign you on github. Or you can work on the avif support #30. Either is fine. I'll try to deal with the other thing.

Also don't forget to join DJT on Telegram or Matrix because we usually discuss everything related to AJATT development there.

@kanjieater
Copy link
Author

Unfortunately I don't have time currently to contribute myself (I'm in the middle of restoring an akiya). I'll instead just disable the add-on and run in batch on a month or so interval until a maintainer is able to address it.

@tatsumoto-ren
Copy link
Member

If you would like me to deal with this instead, you may want to donate to ajatt-tools. It can be done here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants