DiODeProject / DiODeProject/MuMoT

LaTeX in output cells slow to render

Open
#162 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
24
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Sometimes takes a couple of minutes after first opening a Notebook and executing a few cells. Example: create a conda env using `environment.yml` then start running the User Manual Notebook. When you get to:

```python
model1.showRates()
```

the output is rendered as

```
$$r_{A}\; (Reaction 5)$$
$$s\; (Reaction 8)$$
$$r_{B}\; (Reaction 6)$$
$$s\; (Reaction 7)$$
$$g_{B}\; (Reaction 2)$$
$$g_{A}\; (Reaction 1)$$
$$a_{B}\; (Reaction 4)$$
$$a_{A}\; (Reaction 3)$$
```

but then a few minutes later is processed typeset by MathJax.

Think the problem is that all existing LaTeX maths (in Markdown cells and in output cells saved within the Notebook) has to be be rendered before any newly-generated LaTeX maths can be (at least that's my guess) and there's a lot of this 'static' LaTeX math in the User Manual. Restarting the kernel once MathJax starts rendering new output doesn't change anything as the problem originates in Javascript land, not Python land, so the Python kernel is irrelevant.

NB I initially thought that the issue was due to the User Manual initially being marked as [untrusted](https://github.com/jupyter/notebook/issues/2707) by Jupyter but that's not the problem: new LaTeX maths in untrusted Notebooks will render eventually.

Also, the following renders v. quickly if its the only content in a Notebook, adding weight to the idea that the quantity of static LaTeX maths in the Notebook file is a factor.

```python
from IPython.display import display, Math
Math('\\frac{a}{b}')
```

No suggestions for fixes yet. Maybe if we could tell IPython.display.Math to use the local LaTeX install (whilst that's still a dependency) instead of MathJax things would render faster.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the delay by creating the conda environment from environment.yml, opening the User Manual Notebook, and running the cell with model1.showRates(). Compare this with the small IPython.display.Math example and investigate the notebook's static and newly generated MathJax content; done means LaTeX output renders without the multi-minute delay.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.