James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.71k stars 533 forks source link

PDF tab does not automatically get refreshed upon finishing building project. #3484

Closed XinzeZhang closed 2 years ago

XinzeZhang commented 2 years ago

Preliminary questions [Required]

I found that the pdf tab does not automatically get refreshed upon finishing building project. I have disabled all the other extensions except Latex Workshop, still, see this issue.

This project is successfully built, and I have opened the pdf tab. If I click the refresh all viewers, the pdf tab would be refreshed. I peek into the developer tools, and the outputs of the extension log are as follows:

[18:47:45] The internal PDF viewer url: http://127.0.0.1:61760/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRlVzZXJzJTJGeGluemUlMkZEb2N1bWVudHMlMkZHaXRIdWIlMkZYaW56ZS1QaEQtVGhlc2lzLUxhdGV4JTJGbWFpbi5wZGY
[18:47:45] Open PDF tab for file:///Users/xinze/Documents/GitHub/Xinze-PhD-Thesis-Latex/main.pdf
[18:47:46] Handle data type: open
[18:47:46] Current workspace folders: ["file:///Users/xinze/Documents/GitHub/Xinze-PhD-Thesis-Latex"]
[18:47:46] Found root file from active editor: /Users/xinze/Documents/GitHub/Xinze-PhD-Thesis-Latex/main.tex
[18:47:46] Keep using the same root file: /Users/xinze/Documents/GitHub/Xinze-PhD-Thesis-Latex/main.tex
[18:47:46] Preview PDF file: file:///Users/xinze/Documents/GitHub/Xinze-PhD-Thesis-Latex/main.pdf
[18:47:46] Handle data type: loaded

There are some warnings when I open the pdf tab with ‘view Latex pdf’:

DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/build/pdf.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/out/viewer/latexworkshop.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/out/viewer/components/connection.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/out/viewer/components/synctex.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/out/viewer/components/pagetrimmer.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/out/viewer/components/utils.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/out/viewer/components/externalpromise.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/out/viewer/components/viewerhistory.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/viewer.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://127.0.0.1:61760/build/pdf.worker.js.map: Fetch through target failed: Target not supported; Fallback: Unknown error
PDF 1e6e57227bf126d3be924781039f9f04 [1.5 xdvipdfmx (20210318) / LaTeX with hyperref] (PDF.js: 2.14.305)

Disable all the other extensions except for LaTeX Workshop, restart VS Code, and check that you still see this issue. [Required]

You still see this issue?: Yes

Make sure to visit the wiki FAQ before filling an issue.

You visited the wiki?: Yes

If your issue is with compiling a document (not having to do with finding the root file of a project), check first that you can compile manually.

You can compile a TeX document manually?: Yes

buglatex

James-Yu commented 2 years ago

I cannot reproduce this bug. Can you please provide a minimal working example?

XinzeZhang commented 2 years ago

Clone the repository in https://github.com/XinzeZhang/HUST-PhD-Thesis-Latex, build the project with the recipe as:

    "latex-workshop.latex.recipes": [
        {
            "name": "xelatex -> bibtex -> xelatex*2",
            "tools": [
                "xelatex",
                "bibtex",
                "xelatex",
                "xelatex"
            ]
        }
    ],

where the xelatex tool and bibtex are defined as:

    {
        "name": "xelatex",
        "command": "latexmk",
        "args": [
            "-xelatex",
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ],
        "env": {}
    },  
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ],
        "env": {}
    },
James-Yu commented 2 years ago

Please make it minimal. Thanks.

XinzeZhang commented 2 years ago

Sorry, I will create an example and reply latter.

XinzeZhang commented 2 years ago

Thanks for the reply. The problem has been solved by changing the definition of 'xelatex' to the following:

    {
        "name": "xelatex",
        "command": "xelatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
        ],
        "env": {}
    }

But the reason why using latexmk -xelatex would cause the auto-refresh and auto-clean to fail has not been figured out by me.

XinzeZhang commented 2 years ago

This problem occurred in my all projects using xelatex to compile Chinese-language-based projects at the last version ‘8.29.0’ of the extension. My tex version is Tex live 2021.

James-Yu commented 2 years ago

Good to know you solved the problem. I also have several projects built with latexmk and xelatex, and I cannot reproduce your issue.