James-Yu / LaTeX-Workshop

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

SyncTeX stops working after Hibernate #4242

Closed michael-markl closed 3 months ago

michael-markl commented 3 months ago

Pre-checks

Environment*

The Issue*

After hibernation (shutdown /h), SyncTex and Backward-SyncTex stop working. After closing and reopening the PDF tab in VSCode, SyncTex works again.

Reproduction Steps

  1. Open a main.tex and a corresponding main.pdf next to it in VSCode
  2. Verify that synctex (e.g. from tex to pdf) works
  3. Hybernate (run shutdown /h)
  4. Power up again
  5. Try to SyncTex (should no longer work)

Expected Behavior

SyncTex functionality should survive a hybernate cycle.

Logs

LaTeX Workshop Output*

Please paste the whole log messages below, not parts of ones. The log should start with New log placeholder %WS1% registered.

[11:06:04.811][Logger] New log placeholder %WS1% registered for c:\Users\markl07\git\unified-flow-model .
[11:06:04.811][Extension] Initializing LaTeX Workshop.
[11:06:05.068][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[11:06:05.151][Server] Creating LaTeX Workshop http and websocket server.
[11:06:05.268][Format][Bib] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[11:06:05.322][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":49924} .
[11:06:05.327][Extension] Extension root: c:\Users\markl07\.vscode\extensions\james-yu.latex-workshop-9.20.0
[11:06:05.327][Extension] $PATH: (REDACTED)
[11:06:05.327][Extension] $SHELL: undefined
[11:06:05.327][Extension] $LANG: undefined
[11:06:05.327][Extension] $LC_ALL: undefined
[11:06:05.327][Extension] process.platform: win32
[11:06:05.327][Extension] process.arch: x64
[11:06:05.327][Extension] vscode.env.appName: Visual Studio Code
[11:06:05.327][Extension] vscode.env.remoteName: undefined
[11:06:05.328][Extension] vscode.env.uiKind: 1
[11:06:05.329][Config] latex-workshop.latex.recipes: [{"name":"latexmk (latexmkrc)","tools":["latexmk_rconly"]},{"name":"latexmk","tools":["latexmk"]},{"name":"latexmk (lualatex)","tools":["lualatexmk"]},{"name":"latexmk (xelatex)","tools":["xelatexmk"]},{"name":"pdflatex -> bibtex -> pdflatex * 2","tools":["pdflatex","bibtex","pdflatex","pdflatex"]},{"name":"Compile Rnw files","tools":["rnw2tex","latexmk"]},{"name":"Compile Jnw files","tools":["jnw2tex","latexmk"]},{"name":"Compile Pnw files","tools":["pnw2tex","latexmk"]},{"name":"tectonic","tools":["tectonic"]}] .
[11:06:05.329][Config] latex-workshop.latex.tools: [{"name":"latexmk","command":"latexmk","args":["-synctex=1","--shell-escape","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=%OUTDIR%","%DOC%"],"env":{}},{"name":"latexmk_rconly","command":"latexmk"}] .
[11:06:05.330][Config] latex-workshop.latex.outDir: "%DIR%/out" .
[11:06:05.337][Config] latex-workshop.synctex.afterBuild.enabled: true .
[11:06:05.338][Config] latex-workshop.linting.chktex.exec.args: ["-wall","-n22","-n30","-n21","-e16","-q"] .
[11:06:05.342][Config] latex-workshop.message.badbox.show: false .
[11:06:05.352][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[11:06:05.354][Root] Current workspace folders: ["file:///c:/Users/markl07/git/unified-flow-model"]
[11:06:05.354][Extension] LaTeX Workshop initialized.
[11:06:05.354][Root] Current workspaceRootDir: file:///c:/Users/markl07/git/unified-flow-model .
[11:06:05.360][Server] valdOrigin is http://127.0.0.1:49924
[11:06:05.379][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:49924/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmMlM0ElMkZVc2VycyUyRm1hcmtsMDclMkZnaXQlMkZ1bmlmaWVkLWZsb3ctbW9kZWwlMkZvdXQlMkZtYWluLnBkZg .
[11:06:05.380][Cacher][Watcher] Watched %WS1%\out\main.pdf with a new .pdf watcher on %WS1%\out .
[11:06:05.380][Event] FILE_WATCHED: "c:\\Users\\markl07\\git\\unified-flow-model\\out\\main.pdf"
[11:06:05.449][Root] Found files that might be root, choose the first one: %WS1%\main.tex .
[11:06:05.449][Root] Root file changed: from %WS1%\main.tex to %WS1%\main.tex, langID latex . Refresh dependencies
[11:06:05.449][Event] ROOT_FILE_CHANGED: "c:\\Users\\markl07\\git\\unified-flow-model\\main.tex"
[11:06:05.450][Cacher][Watcher] Reset.
[11:06:05.450][Cacher][Watcher] Reset.
[11:06:05.452][Cacher] Adding %WS1%\main.tex .
[11:06:05.453][Cacher][Watcher] Watched %WS1%\main.tex with a new .* watcher on %WS1% .
[11:06:05.453][Event] FILE_WATCHED: "c:\\Users\\markl07\\git\\unified-flow-model\\main.tex"
[11:06:05.455][Cacher] Caching %WS1%\main.tex .
[11:06:05.457][Cacher] Input %WS1%\header.tex from %WS1%\main.tex .
[11:06:05.458][Cacher] Adding %WS1%\header.tex .
[11:06:05.458][Cacher][Watcher] Watched %WS1%\header.tex by the .* watcher.
[11:06:05.458][Event] FILE_WATCHED: "c:\\Users\\markl07\\git\\unified-flow-model\\header.tex"
[11:06:05.459][Cacher] Caching %WS1%\header.tex .
[11:06:05.460][Cacher] Updated inputs of %WS1%\header.tex .
[11:06:05.460][Cacher] Parse LaTeX AST: %WS1%\header.tex .
[11:06:05.461][Cacher] Input %WS1%\tikz\NonExistenceNaiveIDE.tex from %WS1%\main.tex .
[11:06:05.461][Cacher] Adding %WS1%\tikz\NonExistenceNaiveIDE.tex .
[11:06:05.462][Cacher][Watcher] Watched %WS1%\tikz\NonExistenceNaiveIDE.tex with a new .* watcher on %WS1%\tikz .
[11:06:05.462][Event] FILE_WATCHED: "c:\\Users\\markl07\\git\\unified-flow-model\\tikz\\NonExistenceNaiveIDE.tex"
[11:06:05.463][Cacher] Caching %WS1%\tikz\NonExistenceNaiveIDE.tex .
[11:06:05.464][Cacher] Updated inputs of %WS1%\tikz\NonExistenceNaiveIDE.tex .
[11:06:05.464][Cacher] Parse LaTeX AST: %WS1%\tikz\NonExistenceNaiveIDE.tex .
[11:06:05.465][Cacher] Updated inputs of %WS1%\main.tex .
[11:06:05.465][Cacher] Parse LaTeX AST: %WS1%\main.tex .
[11:06:05.465][Event] ROOT_FILE_SEARCHED
[11:06:05.579][Cacher] Parsed LaTeX AST: %WS1%\header.tex .
[11:06:05.586][Cacher] Updated elements in 5.47 ms: %WS1%\header.tex .
[11:06:05.586][Event] FILE_PARSED: "c:\\Users\\markl07\\git\\unified-flow-model\\header.tex"
[11:06:05.596][Cacher] Parsed LaTeX AST: %WS1%\tikz\NonExistenceNaiveIDE.tex .
[11:06:05.597][Cacher] Updated elements in 0.57 ms: %WS1%\tikz\NonExistenceNaiveIDE.tex .
[11:06:05.598][Event] FILE_PARSED: "c:\\Users\\markl07\\git\\unified-flow-model\\tikz\\NonExistenceNaiveIDE.tex"
[11:06:06.107][Cacher] Parsed LaTeX AST: %WS1%\main.tex .
[11:06:06.108][File] Calling kpsewhich to resolve scrartcl.cls .
[11:06:06.757][File] kpsewhich returned with 'c:/texlive/2024/texmf-dist/tex/latex/koma-script/scrartcl.cls'.
[11:06:06.793][Cacher] Bib %WS1%\literature.bib from %WS1%\main.tex .
[11:06:06.793][Intelli][Citation] Parsing .bib entries from %WS1%\literature.bib
[11:06:06.794][Intelli][Citation] Parse BibTeX AST from %WS1%\literature.bib .
[11:06:06.794][Cacher][Watcher] Watched %WS1%\literature.bib with a new .bib watcher on %WS1% .
[11:06:06.794][Event] FILE_WATCHED: "c:\\Users\\markl07\\git\\unified-flow-model\\literature.bib"
[11:06:06.794][Cacher] Updated elements in 687.06 ms: %WS1%\main.tex .
[11:06:06.795][Event] FILE_PARSED: "c:\\Users\\markl07\\git\\unified-flow-model\\main.tex"
[11:06:06.797][Cacher] Parsing .fls %WS1%\out\main.fls .
[11:06:06.830][Cacher] Found .aux %WS1%\main.tex from .fls %WS1%\out\main.fls , parsing.
[11:06:06.830][Cacher] Parsed .aux %WS1%\main.tex .
[11:06:06.830][Cacher] Parsed .fls %WS1%\out\main.fls .
[11:06:06.841][Structure] Structure force updated with 0 root sections for %WS1%\main.tex .
[11:06:06.842][Event] STRUCTURE_UPDATED
[11:06:06.843][Intelli][Citation] Parsed 28 bib entries from %WS1%\literature.bib .
[11:06:06.844][Event] FILE_PARSED: "c:\\Users\\markl07\\git\\unified-flow-model\\literature.bib"
[11:06:06.848][Structure] Structure force updated with 7 root sections for %WS1%\main.tex .
[11:06:06.848][Event] STRUCTURE_UPDATED
[11:06:25.116][Viewer] Handle data type: open
[11:06:25.186][Server] Preview PDF file: file:///c:/Users/markl07/git/unified-flow-model/out/main.pdf
[11:06:25.376][Viewer] Handle data type: loaded
[11:06:25.376][Event] VIEWER_PAGE_LOADED
[11:06:25.376][Viewer] SyncTex after build invoked.
[11:06:25.376][Locator] No active editor found.
[11:06:28.993][Root] Current workspace folders: ["file:///c:/Users/markl07/git/unified-flow-model"]
[11:06:28.994][Root] Found root file from active editor: %WS1%\main.tex
[11:06:28.995][Root] Keep using the same root file: %WS1%\main.tex
[11:06:28.995][Event] ROOT_FILE_SEARCHED
[11:06:28.995][Event] STRUCTURE_UPDATED
[11:06:28.996][Event] STRUCTURE_UPDATED
[11:06:29.891][Commander] SYNCTEX command invoked.
[11:06:29.893][Locator] Forward from %WS1%\main.tex to %WS1%\out\main.pdf on line 285.
[11:06:29.983][Viewer] Try to synctex %WS1%\out\main.pdf
<------------  (I triggered hybernation here)
[11:07:41.063][Commander] SYNCTEX command invoked.
[11:07:41.063][Locator] Forward from %WS1%\main.tex to %WS1%\out\main.pdf on line 285.
[11:07:41.115][Viewer] PDF is not opened: %WS1%\out\main.pdf , try opening.
[11:07:41.148][Viewer] Open PDF tab for file:///c:/Users/markl07/git/unified-flow-model/out/main.pdf
[11:07:41.149][Viewer] PDF cannot be opened: %WS1%\out\main.pdf .
<------------  (I waited here to check if something will auto initiliaze in a minute, then I tried again)
[11:08:48.147][Event] STRUCTURE_UPDATED
[11:08:50.791][Commander] SYNCTEX command invoked.
[11:08:50.791][Locator] Forward from %WS1%\main.tex to %WS1%\out\main.pdf on line 285.
[11:08:50.833][Viewer] PDF is not opened: %WS1%\out\main.pdf , try opening.
[11:08:50.849][Viewer] Open PDF tab for file:///c:/Users/markl07/git/unified-flow-model/out/main.pdf
[11:08:50.850][Viewer] PDF cannot be opened: %WS1%\out\main.pdf .

Developer Tools Console

Please paste the whole log messages below, not parts of ones. This console logs can sometimes be very important in many cases. To access the log, click Help -> Toggle Developer Tools -> Console.


11:06:04.522 log.ts:439   ERR Extension 'github.copilot-chat' appears in product.json but enables LESS API proposals than the extension wants.
package.json (LOSES): extensionsAny, newSymbolNamesProvider, interactive, chatProvider, codeActionAI, findTextInFiles, findFiles2, textSearchProvider, terminalDataWriteEvent, terminalExecuteCommandEvent, terminalSelection, terminalQuickFixProvider, mappedEditsProvider, aiRelatedInformation, chatParticipant, chatParticipantAdditions, defaultChatParticipant, chatVariableResolver, contribSourceControlInputBoxMenu, authLearnMore, testObserver, aiTextSearchProvider
product.json (WINS): handleIssueUri, interactive, terminalDataWriteEvent, terminalExecuteCommandEvent, terminalSelection, terminalQuickFixProvider, chatParticipant, chatParticipantAdditions, defaultChatParticipant, chatVariableResolver, chatProvider, mappedEditsProvider, aiRelatedInformation, codeActionAI, findTextInFiles, textSearchProvider, contribSourceControlInputBoxMenu, newSymbolNamesProvider, findFiles2, extensionsAny, authLearnMore, testObserver

11:06:04.535 configurationModels.ts:270 Ignoring latex-workshop.synctex.indicator.enabled as latex-workshop.synctex.indicator is "rectangle" (anonymous) @ configurationModels.ts:270

11:06:04.598 log.ts:419 INFO Started local extension host with pid 17864.

11:06:04.727 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/TeX.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:04.727 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.latex. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/LaTeX.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:04.727 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.bibtex. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/Bibtex.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:04.727 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/markdown-latex-combined.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:04.727 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/cpp-grammar-bailout.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:05.079 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/TeX.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:05.080 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.latex. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/LaTeX.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:05.080 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.bibtex. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/Bibtex.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:05.080 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/markdown-latex-combined.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:05.080 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex. Old grammar file: file:///c%3A/Users/markl07/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json. New grammar file: file:///c%3A/Users/markl07/.vscode/extensions/james-yu.latex-workshop-9.20.0/syntax/cpp-grammar-bailout.tmLanguage.json register @ TMScopeRegistry.ts:46

11:06:05.400 webviewElement.ts:482 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing. mountTo @ webviewElement.ts:482

11:06:07.939 configurationModels.ts:270 Ignoring latex-workshop.synctex.indicator.enabled as latex-workshop.synctex.indicator is "rectangle" (anonymous) @ configurationModels.ts:270

11:06:25.380 log.ts:419 INFO [perf] Render performance baseline is 23ms

<---------- (Possibly I triggered hybernation exactly here)

11:06:40.802 latexworkshop.js:493 Closed: WebScocket to LaTeX Workshop.

11:07:30.501 latexworkshop.js:516 Try to reconnect to LaTeX Workshop: (1/10).

11:07:31.270 connection.js:12 WebSocket connection to 'ws://127.0.0.1:49924/' failed: (anonymous) @ connection.js:12

11:07:31.272 connection.js:16 Uncaught (in promise) Error: Failed to connect to ws://127.0.0.1:49924/ at WebSocket. (connection.js:16:57)

James-Yu commented 3 months ago

We have added some logics to reconnect the viewer with the extension after sleep, but they may not work for all network/pc configs. Reopening PDF is the only robust and reliable solution, unfortunately.

michael-markl commented 3 months ago

Thanks for letting me know; maybe, we can add this to the FAQ in the section SyncTex?

James-Yu commented 3 months ago

Done.

michael-markl commented 3 months ago

It seems the mechanism for reconnecting the web socket is broken. I would open a PR later today (if you'd like to have a look at it).