James-Yu / LaTeX-Workshop

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

Browser PDF viewer not working in Safari #4316

Closed mdimeglio closed 1 month ago

mdimeglio commented 1 month 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: macOS Sonoma 14.2.1
  • Visual Studio Code Version: 1.91.1 (Universal)
  • LaTeX Workshop Version: 10.1.0 (Broken since version 9.21.0)
  • TeX Distribution Version: TeX Live 2023
  • Safari Version: 17.2.1
  • Google Chrome Version: 126.0.6478.127

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.

The Issue*

Please briefly describe the issue you come across.

Since version 9.21.0, the browser PDF viewer no longer displays the PDF when opened in Safari. When opened in Google Chrome, it works correctly.

Reproduction Steps

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

  1. Enable the setting
    "latex-workshop.view.pdf.viewer": "browser"
  2. Open and compile a .tex file
  3. Click the "View LaTeX PDF file" button in the toolbar at the top of the file

Expected Behavior

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

  • This is what the preview looks like in Google Chrome (which is what I expect): Screenshot 2024-07-16 at 10 11 55 am

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.

[10:09:52.397][Logger] New log placeholder %WS1% registered for /Users/mdimeglio/TestProject .
[10:09:52.397][Extension] Initializing LaTeX Workshop.
[10:09:52.471][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[10:09:52.472][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_PATH: "docker"
[10:09:52.500][Server] Creating LaTeX Workshop http and websocket server.
[10:09:52.539][Format][Bib] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["title"],"alignOnEqual":true,"sortFields":true,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[10:09:52.564][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":63255} .
[10:09:52.571][Extension] Extension root: /Users/mdimeglio/.vscode/extensions/james-yu.latex-workshop-10.1.0
[10:09:52.571][Extension] $PATH: /Users/mdimeglio/.ghcup/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/TeX/texbin
[10:09:52.571][Extension] $SHELL: /bin/zsh
[10:09:52.571][Extension] $LANG: undefined
[10:09:52.571][Extension] $LC_ALL: undefined
[10:09:52.571][Extension] process.platform: darwin
[10:09:52.571][Extension] process.arch: arm64
[10:09:52.571][Extension] vscode.env.appName: Visual Studio Code
[10:09:52.571][Extension] vscode.env.remoteName: undefined
[10:09:52.571][Extension] vscode.env.uiKind: 1
[10:09:52.572][Config] latex-workshop.latex.recipes: [{"name":"latexmk 🔃","tools":["latexmk"]},{"name":"latexmk (latexmkrc)","tools":["latexmk_rconly"]},{"name":"latexmk (lualatex)","tools":["lualatexmk"]},{"name":"latexmk (xelatex)","tools":["xelatexmk"]},{"name":"pdflatex ➞ biber ➞ pdflatex × 2","tools":["pdflatex","biber","pdflatex","pdflatex"]},{"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":"tectonic","tools":["tectonic"]}] .
[10:09:52.573][Config] latex-workshop.latex.tools: [{"name":"latexmk","command":"latexmk","args":["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=%OUTDIR%","%DOC%"],"env":{}},{"name":"lualatexmk","command":"latexmk","args":["-synctex=1","-interaction=nonstopmode","-file-line-error","-lualatex","-outdir=%OUTDIR%","%DOC%"],"env":{}},{"name":"xelatexmk","command":"latexmk","args":["-synctex=1","-interaction=nonstopmode","-file-line-error","-xelatex","-outdir=%OUTDIR%","%DOC%"],"env":{}},{"name":"latexmk_rconly","command":"latexmk","args":["%DOC%"],"env":{}},{"name":"pdflatex","command":"pdflatex","args":["-synctex=1","-interaction=nonstopmode","-file-line-error","-output-directory=%OUTDIR%","%DOC%"],"env":{}},{"name":"bibtex","command":"bibtex","args":["%DOCFILE%"],"env":{}},{"name":"rnw2tex","command":"Rscript","args":["-e","knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')"],"env":{}},{"name":"jnw2tex","command":"julia","args":["-e","using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")"],"env":{}},{"name":"jnw2texmintex","command":"julia","args":["-e","using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")"],"env":{}},{"name":"tectonic","command":"tectonic","args":["--synctex","--keep-logs","%DOC%.tex"],"env":{}},{"name":"biber","command":"biber","args":["--output-directory=%OUTDIR%","%DOCFILE%"]}] .
[10:09:52.574][Config] latex-workshop.latex.outDir: "%WORKSPACE_FOLDER%/build/%RELATIVE_DIR%" .
[10:09:52.575][Config] latex-workshop.latex.rootFile.useSubFile: false .
[10:09:52.576][Config] latex-workshop.latex.autoBuild.run: "onSave" .
[10:09:52.578][Config] latex-workshop.view.outline.sync.viewer: true .
[10:09:52.579][Config] latex-workshop.view.pdf.viewer: "browser" .
[10:09:52.579][Config] latex-workshop.view.pdf.internal.synctex.keybinding: "double-click" .
[10:09:52.602][Config] latex-workshop.bibtex-format.sortby: ["title"] .
[10:09:52.602][Config] latex-workshop.bibtex-format.sort.enabled: true .
[10:09:52.602][Config] latex-workshop.bibtex-fields.sort.enabled: true .
[10:09:52.603][Config] editor.acceptSuggestionOnEnter: "off" .
[10:09:52.607][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{","}"]
[10:09:52.608][Root] Current workspace folders: ["file://%WS1%"]
[10:09:52.608][Extension] LaTeX Workshop initialized.
[10:09:52.608][Root] Found root file from active editor: %WS1%/main.tex
[10:09:52.609][Root] Root file changed: from %WS1%/main.tex to %WS1%/main.tex, langID latex . Refresh dependencies
[10:09:52.609][Event] ROOT_FILE_CHANGED: "%WS1%/main.tex"
[10:09:52.609][Cacher][Watcher] Reset.
[10:09:52.609][Cacher][Watcher] Reset.
[10:09:52.610][Cacher] Adding %WS1%/main.tex .
[10:09:52.611][Cacher][Watcher] Watched %WS1%/main.tex with a new .* watcher on %WS1% .
[10:09:52.611][Event] FILE_WATCHED: "%WS1%/main.tex"
[10:09:52.611][Cacher] Caching %WS1%/main.tex .
[10:09:52.612][Event] ROOT_FILE_SEARCHED
[10:09:52.613][Server] valdOrigin is http://127.0.0.1:63255
[10:09:52.621][Cacher] Updated inputs of %WS1%/main.tex .
[10:09:52.621][Cacher] Parse LaTeX AST: %WS1%/main.tex .
[10:09:52.653][Cacher] Parsed LaTeX AST in 32.34 ms: %WS1%/main.tex .
[10:09:52.653][File] Calling kpsewhich to resolve article.cls .
[10:09:52.771][File] kpsewhich returned with '/usr/local/texlive/2023/texmf-dist/tex/latex/base/article.cls'.
[10:09:52.772][Cacher] Updated elements in 118.75 ms: %WS1%/main.tex .
[10:09:52.772][Event] FILE_PARSED: "%WS1%/main.tex"
[10:09:52.773][Structure] Structure force updated with 0 root sections for %WS1%/main.tex .
[10:09:52.773][Event] STRUCTURE_UPDATED
[10:09:55.009][Commander] BUILD command invoked.
[10:09:55.010][Build] The document of the active editor: file://%WS1%/main.tex
[10:09:55.010][Build] The languageId of the document: latex
[10:09:55.010][Root] Current workspace folders: ["file://%WS1%"]
[10:09:55.011][Root] Found root file from active editor: %WS1%/main.tex
[10:09:55.011][Root] Keep using the same root file: %WS1%/main.tex
[10:09:55.011][Event] ROOT_FILE_SEARCHED
[10:09:55.012][Event] STRUCTURE_UPDATED
[10:09:55.012][Build] Building root file: %WS1%/main.tex
[10:09:55.012][Build][Recipe] Build root file %WS1%/main.tex
[10:09:55.014][Build][Recipe] Preparing to run recipe: latexmk 🔃.
[10:09:55.014][Build][Recipe] Prepared 1 tools.
[10:09:55.029][Build][Recipe] outDir: %WS1%/build .
[10:09:55.030][Build] Recipe step 1 The command is latexmk:["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=%WS1%/build/","%WS1%/main"].
[10:09:55.030][Build] env: {}
[10:09:55.030][Build] root: %WS1%/main.tex
[10:09:55.030][Build] cwd: %WS1%
[10:09:55.033][Build] LaTeX build process spawned with PID 7269.
[10:09:56.019][Parser][TexLog] Logged 0 messages.
[10:09:56.020][Build] Finished a step in recipe with PID 7269.
[10:09:56.020][Build] Successfully built %WS1%/main.tex .
[10:09:56.020][Event] BUILD_DONE
[10:09:56.020][Viewer] Call refreshExistingViewer: "%WS1%/build/main.pdf" .
[10:09:56.020][Viewer] Not found PDF viewers to refresh: %WS1%/build/main.pdf
[10:09:56.021][Cacher] Parsing .fls %WS1%/build/main.fls .
[10:09:56.024][Cacher] Found .aux %WS1%/build/main.aux from .fls %WS1%/build/main.fls , parsing.
[10:09:56.024][Cacher] Parsed .aux %WS1%/build/main.aux .
[10:09:56.024][Cacher] Parsed .fls %WS1%/build/main.fls .
[10:10:02.764][Commander] VIEW command invoked with mode: file://%WS1%/main.tex.
[10:10:02.764][Root] Current workspace folders: ["file://%WS1%"]
[10:10:02.764][Root] Found root file from active editor: %WS1%/main.tex
[10:10:02.764][Root] Keep using the same root file: %WS1%/main.tex
[10:10:02.765][Event] ROOT_FILE_SEARCHED
[10:10:02.765][Event] STRUCTURE_UPDATED
[10:10:02.766][Cacher][Watcher] Watched %WS1%/build/main.pdf with a new .pdf watcher on %WS1%/build .
[10:10:02.767][Event] FILE_WATCHED: "%WS1%/build/main.pdf"
[10:10:02.767][Viewer] Serving PDF file at http://127.0.0.1:63255/viewer.html?file=pdf..ZmlsZSUzQSUyRiUyRiUyRlVzZXJzJTJGbWRpbWVnbGlvJTJGVGVzdFByb2plY3QlMkZidWlsZCUyRm1haW4ucGRm
[10:10:02.768][Viewer] Open PDF viewer for file://%WS1%/build/main.pdf
[10:10:02.974][Viewer] Handle data type: open
[10:10:10.181][Event] STRUCTURE_UPDATED

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.

INFO Started local extension host with pid 7229.
workspace.contribution.ts:330 AI generated workspace trust dialog contents not available.
(anonymous) @ workspace.contribution.ts:330
log.ts:419  INFO [perf] Render performance baseline is 19ms
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json.
New grammar file: file:///Users/mdimeglio/.vscode/extensions/james-yu.latex-workshop-10.1.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:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json.
New grammar file: file:///Users/mdimeglio/.vscode/extensions/james-yu.latex-workshop-10.1.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:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json.
New grammar file: file:///Users/mdimeglio/.vscode/extensions/james-yu.latex-workshop-10.1.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:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.
New grammar file: file:///Users/mdimeglio/.vscode/extensions/james-yu.latex-workshop-10.1.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:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.
New grammar file: file:///Users/mdimeglio/.vscode/extensions/james-yu.latex-workshop-10.1.0/syntax/cpp-grammar-bailout.tmLanguage.json

Safari console

[Error] ReferenceError: Can't find variable: PDFViewerApplication
    (anonymous function) (gui.js:200)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (refresh.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (connection.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (utils.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (trimming.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (gui.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (state.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (synctex.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (pdf.mjs.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (latexworkshop.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (viewerhistory.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (l10n.js.map, line 0)
> Selected Element
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (pdf.worker.mjs.map, line 0)
< <div id="viewerContainer" tabindex="0">…</div>
[Error] ReferenceError: Can't find variable: PDFViewerApplication
    (anonymous function) (gui.js:200)
jlelong commented 1 month ago

Unfortunately, I cannot reproduce the issue. I use Safari Version 17.5 (19618.2.12.11.6). My Safari console does not mention issues with PDFViewerApplication.

mdimeglio commented 1 month ago

I've just updated to the latest version of macOS/Safari and that seems to have fixed the issue. Thanks!