Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chrome_print() hangs when printing html with maths produced by Quarto #320

Open
niklz opened this issue Oct 24, 2023 · 6 comments
Open

chrome_print() hangs when printing html with maths produced by Quarto #320

niklz opened this issue Oct 24, 2023 · 6 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@niklz
Copy link

niklz commented Oct 24, 2023

Hi,

I've been having issues using chrome_print() to produce a pdf from html that I have made from a Quarto document. Digging deeper I have found that it's due to the presence of maths symbols. I am not sure where in the document pipeline the failure is occurring, as the same document renders when using RMarkdown instead of Quarto.

Here's a minimal example of what I'm doing:

Quarto doc:

---
title: "test"
format:
  html
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

This is a test with some inline maths. $x$ is a cool variable.

Rendering this to produce 'test.html' I am then experiencing the failure (where chrome_print() hangs indefinitely) when running:

chrome_print(
  "test.html", 
  output = "test.pdf",
)

I get the following errors:

Error in force(expr) : Failed to generate output in 30 seconds (timeout).
[2023-10-24 15:03:05] [error] handle_read_frame error: asio.system:10054 (An existing connection was forcibly closed by the remote host.)

Any advice or ideas of things I could check would be appreciated!

Session info:

> sessionInfo()
R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=C                              LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.11       pak_0.4.0         ps_1.7.5          later_1.3.1       digest_0.6.33     mime_0.12         R6_2.5.1         
 [8] jsonlite_1.8.7    magrittr_2.0.3    evaluate_0.22     rlang_1.1.1       cli_3.6.1         promises_1.2.0.1  rstudioapi_0.15.0
[15] rmarkdown_2.23    tools_4.2.3       servr_0.24        processx_3.8.2    httpuv_1.6.5      xfun_0.39         yaml_2.3.7       
[22] fastmap_1.1.1     compiler_4.2.3    htmltools_0.5.6.1 websocket_1.4.1   pagedown_0.20     knitr_1.44   
@cderv
Copy link
Collaborator

cderv commented Oct 24, 2023

Error in force(expr) : Failed to generate output in 30 seconds (timeout).

About this, did you try to increase the timeout already ?

@niklz
Copy link
Author

niklz commented Oct 25, 2023

Error in force(expr) : Failed to generate output in 30 seconds (timeout).

About this, did you try to increase the timeout already ?

Yes, I tried increasing the timeout to no avail. Also, if you remove the inline maths (by deleting the $ symbols in the .qmd) chrome_print() works flawlessly and very quickly.

@cderv
Copy link
Collaborator

cderv commented Oct 25, 2023

Thanks for the report. I'll try to have a look into this. It seems related to how mathjax is loaded then... something seems to hang the page load and the expected websocket message is not sent. This is not easy to debug.

In the meantime you could try another chrome R package (like chromote or crrri) that could communicate with chrome, but I suspected it will be the same error. Changing the HTML math method for the format may be the best workaround for now.

@cderv cderv added the bug an unexpected problem or unintended behavior label Oct 25, 2023
@cderv cderv moved this from Backlog to To discuss / To plan in R Markdown Team Projects Oct 25, 2023
@yihui
Copy link
Member

yihui commented Oct 25, 2023

I'd suggest that you try katex instead of the default mathjax: https://quarto.org/docs/output-formats/html-basics.html#latex-equations katex is often a lot faster in rendering math expressions.

@niklz
Copy link
Author

niklz commented Oct 25, 2023

I'd suggest that you try katex instead of the default mathjax: https://quarto.org/docs/output-formats/html-basics.html#latex-equations katex is often a lot faster in rendering math expressions.

I can confirm that using html-math-mathod: katex in the html output options produces html with maths symbols which chrome_print() can handle, thanks!

I can consider this issue closed, however I guess the bug with mathjax is still at large

@cderv
Copy link
Collaborator

cderv commented Oct 26, 2023

We'll keep that open to see how we could fix the issue with this Mathjax loading. I don't think this is a timing issue but rather something related to how it is loading, and the websocket process not intercepting and so hanging.

@cderv cderv moved this from To discuss / To plan to Backlog in R Markdown Team Projects Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
Status: Backlog
Development

No branches or pull requests

3 participants