fonol / anki-search-inside-add-card

An add-on providing full-text-search and PDF reading functionality to Anki's Add card dialog
https://ankiweb.net/shared/info/1781298089
GNU Affero General Public License v3.0
178 stars 24 forks source link

Opening a PDF takes more than 30 minutes and causes high CPU usage #357

Open mperry2 opened 1 year ago

mperry2 commented 1 year ago

Describe the bug When a PDF is opened in the viewer, it will take more than 30 minutes for the PDF to appear during which anki.exe is using 90% CPU. I say "more than" because I closed Anki after 30 minutes as it clearly wasn't working. During this time the there will be a small dialog box that has a blue expanding circle animation and the text "Loading PDF" or "Initializing Reader". It spends the most time on Initializing Reader.

I tried another PDF with fewer pages and that one took 37 seconds before it appeared successfully. I'm not sure if the time taken has something to do with the number of pages or not. I have PDFs to read that are books and therefore are between 200 to 600 pages each.

I've attached both PDFs that I used so you can try to reproduce the issue.

  1. ansible_network.pdf (did not open after 30 minutes)
  2. nistspecialpublication800-145.pdf (opened in ~37 seconds)

To Reproduce Steps to reproduce the behavior:

  1. Click on Add to open the Add window
  2. Click on Notes button -> New
  3. In New Note dialog, enter a title, then click Source button, then PDF.
  4. Choose a PDF in the file requester.
  5. Click Create in the New Note window. The window will close.
  6. Click on the PDF Notes icon (#⁠1 in first screenshot below). The new PDF file entry will appear in the window.
  7. Click on the book icon in the box with the PDF name (#⁠2 in first screenshot below). The gray PDF viewer will appear.
  8. The PDF viewer will say Loading PDF and then Initializing Reader with a blue expanding circle. Anki will use about 90% CPU. (second screenshot)

Expected behavior I expected to see the PDF appear within a few seconds or less without excessive CPU usage.

Screenshots PDFViewerBug1 PDFViewerBug2

Environment

mperry2 commented 1 year ago

I did some more testing and found the following.