James-Yu / LaTeX-Workshop

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

PDF reader failed on ssh #4169

Closed Fourthbus closed 6 months ago

Fourthbus commented 6 months ago

Pre-checks*

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

  • [x] The issue has not been reported in this repository. (this has been mentioned in #2206 but it's over two years. I did not experience the issue until very recently)
  • [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: Windows 11, Mac OS 13.6.3 (console output generated on mac)
  • Visual Studio Code Version: 1.86.2
  • LaTeX Workshop Version: 9.18.2
  • TeX Distribution Version: TeX Live 2023

The Issue*

I connected to a latex directory on a remote server via ssh, when I tried to view a pdf, the page failed to render (see attached photo):

image

Reproduction Steps

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

  1. Connect to remote VS code via ssh
  2. Open .pdf

Expected Behavior

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

  • pdf display normally as the behaviour on a wsl session.

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.

[12:12:59.572][Viewer][Panel] Internal PDF viewer at http://127.0.0.1:40725/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmhvbWUlMkZ6YzI4MiUyRmxhdGV4X2RvY3MlMkZjb29saW5nX2NmZCUyRmJ1aWxkJTJGY29uZmlndXJhdGlvbi5wZGY .
[12:12:59.574][Cacher][Watcher] Watched %WS1%/build/configuration.pdf .
[12:12:59.574][Event] FILE_WATCHED: "%WS1%/build/configuration.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.


webviewElement.ts:512 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:512
M @ overlayWebview.ts:218
claim @ overlayWebview.ts:120
kb @ webviewEditor.ts:178
setInput @ webviewEditor.ts:169
await in setInput (async)
S @ editorPanes.ts:445
L @ editorPanes.ts:270
openEditor @ editorPanes.ts:146
(anonymous) @ editorGroupView.ts:1124
Eb @ editorGroupView.ts:1148
Db @ editorGroupView.ts:1106
openEditor @ editorGroupView.ts:1012
openEditor @ editorService.ts:556
await in openEditor (async)
(anonymous) @ explorerView.ts:529
y @ event.ts:1127
fire @ event.ts:1158
j @ listService.ts:778
g @ listService.ts:749
(anonymous) @ listService.ts:705
y @ event.ts:1127
fire @ event.ts:1158
(anonymous) @ event.ts:118
y @ event.ts:1127
fire @ event.ts:1158
(anonymous) @ event.ts:118
y @ event.ts:1127
fire @ event.ts:1158
u @ listWidget.ts:775
u @ abstractTree.ts:2255
(anonymous) @ event.ts:169
y @ event.ts:1127
fire @ event.ts:1158
(anonymous) @ event.ts:118
y @ event.ts:1127
fire @ event.ts:1158
y @ event.ts:40
   GET http://127.0.0.1:40725/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmhvbWUlMkZ6YzI4MiUyRmxhdGV4X2RvY3MlMkZjb29saW5nX2NmZCUyRmJ1aWxkJTJGY29uZmlndXJhdGlvbi5wZGY net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)

(anonymous) @ index.html:1003 setTimeout (async) onFrameLoaded @ index.html:1001 (anonymous) @ index.html:1032 127.0.0.1:40725/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmhvbWUlMkZ6YzI4MiUyRmxhdGV4X2RvY3MlMkZjb29saW5nX2NmZCUyRmJ1aWxkJTJGY29uZmlndXJhdGlvbi5wZGY:35

   GET http://127.0.0.1:40725/viewer.css net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)

127.0.0.1:40725/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRmhvbWUlMkZ6YzI4MiUyRmxhdGV4X2RvY3MlMkZjb29saW5nX2NmZCUyRmJ1aWxkJTJGY29uZmlndXJhdGlvbi5wZGY:38

   GET http://127.0.0.1:40725/out/viewer/latexworkshop.js net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)

## Anything Else?
> _Add any other context about the problem below._
When I open the URL of the viewer from firefox, (i.e. http://127.0.0.1:40725/viewer.html), the view is the same and the console suggests some content loading error too.

Loading failed for the module with source “http://127.0.0.1:40725/out/viewer/latexworkshop.js”. viewer.html:38:59 Content-Security-Policy: The page's settings blocked the loading of a resource at inline ("default-src"). sandbox eval code:107:351 Source map error: Error: request failed with status 404 Resource URL: http://127.0.0.1:40725/build/pdf.mjs Source Map URL: pdf.mjs.map

Fourthbus commented 6 months ago

I suspect there's something to do with the error output

Content-Security-Policy: The page's settings blocked the loading of a resource at inline ("default-src").

The page loads properly when I type the URL to the host computer (despite vscode UI isn't running there). However, the same page would not be accessible on a remote instance with ssh port forwarding.

James-Yu commented 6 months ago

CSP for viewer.html has not been changed for two years. Please refer to the remote-ssh extension for possible changes that may lead to the issue, which I am not aware of.

https://github.com/James-Yu/LaTeX-Workshop/blame/master/viewer/viewer.html#L28

ben-z commented 6 months ago

I downgraded the Remote - SSH extension from 0.108.0 to 0.107.1 and this error went away. Strangely, I can't find the changelog for the remote ssh extension.

Fourthbus commented 6 months ago

I downgraded the Remote - SSH extension from 0.108.0 to 0.107.1 and this error went away. Strangely, I can't find the changelog for the remote ssh extension.

I agree with you. It seems to be related to Remote-SSH. When I manually do port forwarding ssh -L to the exact same port it works without any problem.

There's seems to have similar issue https://github.com/microsoft/vscode-remote-release/issues/9594 with other peoples' web page.

Fourthbus commented 6 months ago

Solution is here https://github.com/microsoft/vscode-remote-release/issues/9548

"remote.SSH.useExecServer": false