Forum Bugs

Page of rendered MathJax extremely slow/causing prince to hang

alecjacobson
I've been experimenting with using MathJax + MathJax-node + prince to create PDFs containing typeset math. I'm very happy with the quality I'm seeing so far, but when I recently tried a larger document I found that prince took a very long time to finish. It might even be hanging.

Attached is `full-math.html`, when I issue

prince full-math.html -o full-math.pdf

the command runs for **over an hour** on my MacBook Air running Mac 10.11.6. I have prince version `Prince 10 rev 7` (I also tried the "latest build", but this had the same issue). I eventually just killed this command so I don't know if it would have ever finished.

I tried a slightly smaller version of the same file (`half-math.html` attached). This finishes but takes **over 3 minutes** which is already very/too slow. For what it's worth, Safari can render these pages in roughly a second.

I noticed that the last equation of `half-math.html` causes the time to jump from some seconds to three minutes. These equations seem to have a "deep DOM" (many nested <span> objects). Maybe prince is choking on these?

> These files are automatically generated by running `multimarkdown` on a markdown .md file and then using mathjax-node to pre-render the TeX math objects.

> The SVG-based solution for mathjax on the http://www.princexml.com/forum/topic/2971/using-mathjax-with-princexml thread _works_ in the sense that it renders quickly, but the SVG math is far less beautiful than the HTML math in my examples (prince seems to do a great job rendering the HTML math output of mathjax, just takes forever to do it).
  1. full-math.html226.7 kB
    Killed after prince ran for an hour
  2. half-math.html114.4 kB
    Prince takes over a minute
mikeday
Interesting, this document appears to be triggering some pathological behaviour, because it's really not that big. We will investigate and see what we can figure out.