allefeld / atom-pdfjs-viewer

Themed, fully featured PDF viewer for the Atom editor
MIT License
12 stars 3 forks source link

After rebuilding a latex file, the viewer sometimes shows the PDF concatenated 2 times #11

Closed avm99963 closed 3 years ago

avm99963 commented 3 years ago

This happens sometimes when performing the following steps:

  1. Open a PDF in Atom.
  2. Rebuild the PDF.
  3. The PDF will be reloaded in Atom, and sometimes the PDF will be shown 2 times, as is shown in the following GIF:

Kapture 2021-04-25 at 13 49 09

In my case, I'm using pdfjs-viewer 1.0.1 (although this also occurred in previous versions) in Atom 1.56.0 using macOS 10.15.7.

allefeld commented 3 years ago

Hm, I've never seen this, though I use the package all the time. Are you certain that it isn't the PDF file itself that is broken, containing the same pages twice? Can you provide a recipe how to reproduce this?

Ludoric commented 3 years ago

I have been having this problem too. When reloading the page a new set of pdf.worker.js threads are created, and the old ones are not closed. I suspect that the view duplication is a result of having multiple threads all trying to display the document to the same window.

Calling win.PDFViewerApplication.close() before opening the file https://github.com/allefeld/atom-pdfjs-viewer/blob/a9c8c8890572c9c81dad1a38704320f0717b963a/lib/pdfjs-viewer-view.js#L255 appears to fix both the view duplication and remove the excess threads.

I think I have created a pull request for this change

avm99963 commented 3 years ago

Awesome, thanks @Ludoric!

@allefeld: I'm a little bit busy right now, but given that Ludoric already submitted a PR, maybe that will fix it. If it doesn't, I'll try to share here some detailed reproduction steps when I have some time. Thanks!!

allefeld commented 3 years ago

Thanks @Ludoric! I merged your pull request and published a new version of the package.

Please let me know whether this fixes the problem.

avm99963 commented 3 years ago

I've been writing a LaTeX file and recompiling it a lot of times, and this doesn't happen now, so it seems the PR really fixed the issue. I'll therefore close this issue.

Thanks to the both of you! :)

allefeld commented 2 years ago

@Ludoric, you are the only person who has committed to this repository except me. I intend to abandon this project, since I've moved from Atom to VS Code. Would you be interested in taking it over?