allefeld / atom-pdfjs-viewer

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

pdf refresh fails during TeX rebuild #1

Closed wsdewitt closed 4 years ago

wsdewitt commented 4 years ago

See https://github.com/izuzak/atom-pdf-view/issues/213#issuecomment-575933538

During TeX compilation the atom-pdfjs-viewer window attempts to refresh, but eventually issues this error: image

allefeld commented 4 years ago

Thanks for the report. I suspect the problem is that the PDF is still being written at the time the PDF reload is triggered.

I assume from what you wrote on the other issue, that there is a LaTeX process that has produced the PDF, it is then viewed with my package, and then the LaTeX process is rerun recreating the PDF in-place. Is that correct?

The best way for me to correct this would be to reproduce it. Can you share the exact LaTeX command that recreates the PDF, and optimally also all the input files you used for that run? If possible, try to come up with a minimal example (set of input files) that creates the problem for you.

micahjsmith commented 4 years ago

I'm also experiencing this same problem. I'm trying to create a reproducible example for you to debug with, but not able to share the paper that I'm working on.

Some observations:

Is there any debugging information that would be helpful in the absence of a reproducible example?

allefeld commented 4 years ago

@micahjsmith, a reproducible example would be great.

I think I've been seeing something similar. When a PDF is open in Atom and Atom gets closed, the information on the open PDF is saved (serialized). If then Atom is started again later but the PDF has been deleted in the meantime (e.g. from /tmp), the tab is recreated but I get the red error message – and the message also doesn't go away if I recreate and reopen the PDF. It only works again after closing the PDF tab. It seems like the pdf.js viewer is completely shutting down after it couldn't find the file once.

I'll try to look into it soon and search for a workaround.

allefeld commented 4 years ago

@micahjsmith, I've made changes that I think should solve the problem, but I didn't yet publish the new version on Atom packages because I only tested it briefly. Would you try it from the current state of the repository? I think

apm install https://github.com/allefeld/atom-pdfjs-viewer.git

should work. It is possible that you have to uninstall the regular package first.

If it works, great & let me know, if not it would be helpful if you open the JavaScript developer console (Ctrl-Shift-I on my machine) and post the last few messages.

micahjsmith commented 4 years ago

This works! Thanks for following up on this.

I tried the same debugging as above. It takes about 20 seconds for the paper to compile. latexmk produces complete/valid PDFs 3 times in its overall compilation process. each time the PDF is compiled, the document disappears from pdfjs-viewer with a red error bar, and at the end of sub-compilation the document appears correctly. finally, at the end of the overall compilation, the document appears correctly.

allefeld commented 4 years ago

This works!

Great, then I'll push it to Atom packages.

the document disappears from pdfjs-viewer with a red error bar

I'm afraid I don't think I can fix that from my end. I don't know which package you use to start the compilation, but maybe it can be configured to use a temporary file, which only in the end is moved to the file that is displayed in pdfjs-viewer?

allefeld commented 4 years ago

fixed in e12c914b0c54a25dea7e18f4ad1a5cd28be425c9

micahjsmith commented 4 years ago

Thanks again!

I'm afraid I don't think I can fix that from my end.

Agreed, this is not an issue IMO