James-Yu / LaTeX-Workshop

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

PDF Viewer fails to open pdf over WSL-within-SSH after first file #4302

Closed jhanschoo closed 2 weeks ago

jhanschoo commented 2 weeks ago

Please fill the following fields with a star (*) and provide as much related information as possible.

Pre-checks*

Please change the following [ ] to [x] for confirmation.

  • [x] The issue has not been reported in this repository.
  • [x] The issue remains after disabling all other extensions and restarting Visual Studio Code.
  • [x] The FAQ cannot address the issue.
  • [x] The issue is not related to compiling a document, or the document can be successfully compiled in the OS terminal but not in Visual Studio Code with this extension.

Environment*

Please write exact version numbers instead of descriptors such as latest.

  • Operating System: Host & SSH remote: Windows 11; WSL distro: Ubuntu 22.04
  • Visual Studio Code Version: 1.90.2, also present on 1.91.0-insider
  • LaTeX Workshop Version: 10.0.0
  • TeX Distribution Version: N/A

Please list the environment and version number if you are using VSCodium, Snap or Flatpack versions of Visual Studio Code, and/or Visual Studio Code Remote Containers/SSH/WSL.

  • Remote - SSH Version: v0.113.2024062515, also present on v0.113.2024062515
  • WSL Version: v0.88.2

The Issue*

Please briefly describe the issue you come across.

  • The pdf viewer usually fails to open files past the first file (that launched the extension) when using a WSL-within-SSH vscode environment. That is, where the main remote VSCode server runs in a WSL installation in the remote server, which is connected to via SSH. Admittedly, this is a niche setup.
  • There may be further SyncTeX etc. issues not captured here.
  • This issue may be related to other PDF viewing-over-remote issues, especially those that have a workaround by choosing to not use an exec server on the remote.

Reproduction Steps

Please list out the steps to reproduce your bug. Include relevant environmental variables or any other configuration.

  1. Connect to a remote server over SSH
  2. Connect to the WSL instance in the remote server
  3. While the extension is not yet loaded, open a pdf file. It usually works.
  4. Open a different pdf file a few seconds after the first file loads. It usually does not properly load.
  5. Open a pdf file a few minutes after the second loads. It might load.

Expected Behavior

What were you expecting to see? Include any relevant examples or documentation links.

  • The second PRF viewer should properly open the file.

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:59:31.647][Extension] Initializing LaTeX Workshop.
[11:59:31.729][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[11:59:31.729][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_PATH: "docker"
[11:59:31.743][Server] Creating LaTeX Workshop http and websocket server.
[11:59:31.782][Format][Bib] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[11:59:31.801][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":37757} .
[11:59:31.828][Extension] Extension root: /home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0
[11:59:31.828][Extension] $PATH: /home/jhanschoo/.vscode-insiders/cli/servers/Insiders-4580ba51fe1914ca29916f829adb35930089b013/server/bin/remote-cli:REDACTED
[11:59:31.828][Extension] $SHELL: /usr/bin/zsh
[11:59:31.828][Extension] $LANG: C.UTF-8
[11:59:31.828][Extension] $LC_ALL: undefined
[11:59:31.829][Extension] process.platform: linux
[11:59:31.829][Extension] process.arch: x64
[11:59:31.829][Extension] vscode.env.appName: Visual Studio Code - Insiders
[11:59:31.829][Extension] vscode.env.remoteName: wsl
[11:59:31.829][Extension] vscode.env.uiKind: 1
[11:59:31.848][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{","}"]
[11:59:31.849][Root] Current workspace folders: undefined
[11:59:31.849][Extension] LaTeX Workshop initialized.
[11:59:31.850][Root] Current workspaceRootDir:  .
[11:59:31.850][Root] No root file found.
[11:59:31.850][Structure] Structure cleared on undefined root.
[11:59:31.850][Event] ROOT_FILE_SEARCHED
[11:59:31.851][Event] STRUCTURE_UPDATED
[11:59:31.853][Server] valdOrigin is http://127.0.0.1:37757
[11:59:31.979][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:37757/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmhvbWUlMkZqaGFuc2Nob28lMkZub3RlcyUyRmJhYnlfcnVkaW4lMkYzXzE1LnBkZg .
[11:59:31.980][Cacher][Watcher] Watched /home/jhanschoo/REDACTED/3_15.pdf with a new .pdf watcher on /home/jhanschoo/notes/baby_rudin .
[11:59:31.980][Event] FILE_WATCHED: "/home/jhanschoo/REDACTED/3_15.pdf"
[11:59:32.732][Viewer] Handle data type: open
[11:59:32.769][Server] Preview PDF file: file:///home/jhanschoo/REDACTED/3_15.pdf
[11:59:33.387][Viewer] Handle data type: loaded
[11:59:33.387][Event] VIEWER_PAGE_LOADED
[11:59:38.592][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:37757/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmhvbWUlMkZqaGFuc2Nob28lMkZub3RlcyUyRmJhYnlfcnVkaW4lMkYxLnBkZg .
[11:59:38.592][Cacher][Watcher] Watched /home/jhanschoo/REDACTED/1.pdf by the .pdf watcher.
[11:59:38.592][Event] FILE_WATCHED: "/home/jhanschoo/REDACTED/1.pdf"
[12:11:51.550][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:37757/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmhvbWUlMkZqaGFuc2Nob28lMkZub3RlcyUyRmJhYnlfcnVkaW4lMkYxLnBkZg .
[12:11:51.551][Cacher][Watcher] Watched /home/jhanschoo/REDACTED/1.pdf by the .pdf watcher.
[12:11:51.551][Event] FILE_WATCHED: "/home/jhanschoo/REDACTED/1.pdf"
[12:12:11.910][Viewer] Handle data type: open
[12:12:11.964][Server] Preview PDF file: file:///home/jhanschoo/REDACTED/1.pdf
[12:12:12.133][Viewer] Handle data type: loaded
[12:12:12.133][Event] VIEWER_PAGE_LOADED

Remote-SSH output

[11:59:27.855] Log Level: 2
[11:59:27.912] Opening exec server for ssh-remote+epithymia-win11
[11:59:27.917] VS Code version: 1.91.0-insider
[11:59:27.917] Remote-SSH version: remote-ssh@0.113.2024062515
[11:59:27.917] win32 x64
[11:59:27.921] Initizing new exec server for ssh-remote+epithymia-win11
[11:59:27.925] Using commit id "4580ba51fe1914ca29916f829adb35930089b013" and quality "insider" for server
[11:59:27.930] Install and start server if needed
[11:59:27.936] Checking ssh with "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin\ssh.exe -V"
[11:59:27.939] Got error from ssh: spawn C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin\ssh.exe ENOENT
[11:59:27.939] Checking ssh with "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\libnvvp\ssh.exe -V"
[11:59:27.941] Got error from ssh: spawn C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\libnvvp\ssh.exe ENOENT
[11:59:27.941] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V"
[11:59:27.942] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT
[11:59:27.942] Checking ssh with "C:\WINDOWS\ssh.exe -V"
[11:59:27.943] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT
[11:59:27.943] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V"
[11:59:27.944] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT
[11:59:27.944] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[11:59:27.945] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[11:59:27.945] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[11:59:27.993] > OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3

[11:59:27.996] Remote command length: 4939/8192 characters
[11:59:27.996] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 60519 "epithymia-win11" powershell
[11:59:27.999] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[11:59:29.460] > Windows PowerShell
> Copyright (C) Microsoft Corporation. All rights reserved.Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindowsPS C:\Users\jhans>
> PS C:\Users\jhans> $uuid="b9f890091d02"
> PS C:\Users\jhans>]0;C:\WINDOWS\System32\cmd.exe"${uuid}: running"
> b9f890091d02: running
> PS C:\Users\jhans> "b9f890091d02: pauseLog"
> b9f890091d02: pauseLog
[11:59:29.460] Got some output, clearing connection timeout
[11:59:29.540] > 
[11:59:29.699] > Looking for existing CLI in C:\Users\jhans\.vscode-server-insiders
> Found installed CLI
[11:59:29.774] > 
> Starting cli: & 'C:\Users\jhans\.vscode-server-insiders\code-insiders-4580ba51fe
> e1914ca29916f829adb35930089b013.exe' command-shell --cli-data-dir 'C:\Users\jhans
> s\.vscode-server-insiders\cli' --parent-process-id 1884 --on-host 127.0.0.1 --on-
> -port --require-token ff6b6084-786a-49f3-a8e5-7c3d8b2bf6c2 *> 'C:\Users\jhans\App
> pData\Local\Temp\tmp1323.tmp'
[11:59:30.025] > b9f890091d02: start
> SSH_AUTH_SOCK====
> listeningOn==62109==
> osReleaseId==windows==
> osVersion==10.0.22631==
> arch==x64==
> platform==windows==
> unpackResult====
> didLocalDownload==False==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime==33==
> execServerToken==aa1a1111-111a-11a1-a1a1-1a1a1a1aa1a1==
> b9f890091d02: end
> 23068, watching 1884
[11:59:30.026] Received install output: 
SSH_AUTH_SOCK====
listeningOn==62109==
osReleaseId==windows==
osVersion==10.0.22631==
arch==x64==
platform==windows==
unpackResult====
didLocalDownload==False==
downloadTime====
installTime====
extInstallTime====
serverStartTime==33==
execServerToken==aa1a1111-111a-11a1-a1a1-1a1a1a1aa1a1==

[11:59:30.026] Remote server is listening on port 62109
[11:59:30.026] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":62109},"osReleaseId":"windows","arch":"x64","sshAuthSock":"","platform":"windows","execServerToken":"aa1a1111-111a-11a1-a1a1-1a1a1a1aa1a1"},"serverStartTime":33,"installUnpackCode":""}
[11:59:30.029] Starting forwarding server. local port 60540 -> socksPort 60519 -> remotePort 62109
[11:59:30.030] Forwarding server listening on port 60540
[11:59:30.030] Waiting for ssh tunnel to be ready
[11:59:30.031] [Forwarding server port 60540] Got connection 0
[11:59:30.032] Tunneled port 62109 to local port 60540
[11:59:30.032] Resolved "ssh-remote+epithymia-win11" to "port 60540"
[11:59:30.032] Resolving exec server at port 60540
[11:59:30.033] [Forwarding server port 60540] Got connection 1
[11:59:30.041] > 
[11:59:30.050] Exec server for ssh-remote+epithymia-win11 created and cached
[11:59:30.057] Opening exec server for ssh-remote+epithymia-win11
[11:59:30.058] Opening exec server for ssh-remote+epithymia-win11
[11:59:30.063] Verified and reusing cached exec server for ssh-remote+epithymia-win11
[11:59:30.063] Verified and reusing cached exec server for ssh-remote+epithymia-win11
[11:59:30.621] Opening exec server for ssh-remote+epithymia-win11
[11:59:30.626] Verified and reusing cached exec server for ssh-remote+epithymia-win11

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.

log.ts:419  INFO Invoking resolveAuthority(wsl)...
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][0ms] obtaining proxy...
log.ts:419  INFO Started local extension host with pid 31616.
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][825ms] invoking...
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][1828ms] waiting...
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][2827ms] waiting...
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][3827ms] waiting...
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][4567ms] returned Managed(1)
log.ts:419  INFO resolveAuthority(wsl) returned 'Managed(1)' after 4567 ms
log.ts:419  INFO Creating a socket (renderer-Management-51c155d5-e9f3-475f-81e6-5ef00a2c6fa0)...
log.ts:419  INFO Creating a socket (renderer-ExtensionHost-4e6af6eb-a39e-416a-96ad-26b865f0bf12)...
log.ts:419  INFO Creating a socket (renderer-Management-51c155d5-e9f3-475f-81e6-5ef00a2c6fa0) was successful after 105 ms.
log.ts:419  INFO Creating a socket (renderer-ExtensionHost-4e6af6eb-a39e-416a-96ad-26b865f0bf12) was successful after 106 ms.
log.ts:439   ERR Ignoring latex-workshop.synctex.indicator.enabled as latex-workshop.synctex.indicator is "rectangle"
9An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
log.ts:419  INFO [perf] Render performance baseline is 25ms
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/TeX.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.latex.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/LaTeX.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.bibtex.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/Bibtex.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/markdown-latex-combined.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/cpp-grammar-bailout.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/TeX.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.latex.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/LaTeX.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.bibtex.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/Bibtex.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/markdown-latex-combined.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex.
Old grammar file: file:///c%3A/Users/jhans/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.
New grammar file: vscode-remote://wsl%2BUbuntu@ssh-remote%2Bepithymia-win11/home/jhanschoo/.vscode-server-insiders/extensions/james-yu.latex-workshop-10.0.0/syntax/cpp-grammar-bailout.tmLanguage.json

Anything Else?

Add any other context about the problem below.

James-Yu commented 2 weeks ago

This is most likely a problem regarding port forward of the said environment, which is out of control of this extension. You may seek for help in their repo.

jhanschoo commented 4 days ago

To follow up: indeed using wireshark it seems to me the issue lay in port forwarding: I can see the request made to localhost by the client, but cannot see the request arrive in the wsl environment, when it fails.

I've managed to workaround the issue by installing an OpenSSH server in the WSL environment and SSHing into it with the win11 server as proxy and HostKeyAlias in the config, which seems to work out-of-the-box, pleasantly surprisingly.