17 views
Skip to first unread message

Paul Libbrecht

unread,
Jun 23, 2025, 1:51:02 PMJun 23
to MathJax Users

Hello dear MathJaxers,

While playing with MathCAT, I was surprised to crash on a simple expression that contained double struck unicode characters.

It appears that MathJax.mathml2chtml(‘<math><mi>ℝ</mi></math>’) is the cause of a crash (stacktrace below).
Using MathCAT differently displayed that it had no issue with this expression (pronounced as “the set of real numbers”).

Changing from Mathjax-beta-4 to Mathjax-beta-7 changed nothing.
I had similar crashes with the integers and the complex numbers.
Should I open an issue?

Paul

Uncaught Error: MathJax retry
Fn https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getChar https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getVariantChar https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
computeBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getOuterBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
computeBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
computeBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getOuterBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
computeBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getOuterBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
computeBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
computeBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getOuterBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
getLineBBox https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
handleSpace https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
standardChtmlNodes https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
toCHTML https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
toCHTML https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
processMath https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
toDOM https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
typeset https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
typeset https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
methodActions https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
renderConvert https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
convert https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
convert https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
n https://cdn.jsdelivr.net/npm/mat...@4.0.0-beta.7/tex-mml-chtml.js:1
<anonymous> debugger eval code:1

Davide Cervone

unread,
Jun 23, 2025, 2:39:59 PMJun 23
to mathja...@googlegroups.com
Paul:

There is no need to file an issue, as this is actually the correct behavior for MathJax v4.  See for example

https://github.com/mathjax/MathJax/issues/3113

and the discussion there.  When MathJax needs to perform some asynchronous action (loading files or other data), MathJax must wait for that data to arrive and that means the typesetting must be interrupted and restarted after the data loads.  MathJax handles that by throwing a "MathJax retry" error that is supposed to be caught by code higher up in the process that waits for that asynchronous action to complete and then starts eh typesetting again.

The loading od asynchronous files are mediated by JavaScript promise structures, and the promise-based calls, like MathJax.mathml2chtmlPromise() are the ones that know how to handle the retry messages.  You, however, are calling the synchronous call MathJax.mathml2chtml(), which will throw this error if it encounters something that  requires loading more data and expects you to handle that retry yourself (since you have called the synchronous version of the function).

The kinds of things that cause MathJax to need more data are things like loading TeX extensions (via the \require{} macro, or by the auto-load extension).  In Mathjax v4, the fonts now include much greater character coverage than in v3, and the data for that extra coverage is pretty extensive, so it has been broken down into smaller pieces that are loaded when needed.  The double-struck character data is in one such dynamically loaded data file, so in MathJax v4, that will cause an asynchronous file load to occur, as signaled by the retry error.  That means you need to either handle those yourself (for example, using the mathjax.handleRetriedFor() command), or use one of the promise-based calls instead. See the release notes for 4.0.0-alpha.1


which discuss the need for these promises for the new fonts.  Using the promise-based calls is the easiest way to deal with this, though that does mean you may need to restructure your code in order to handle the asynchronicity.  Alternatively, it is possible to load all the font data (though that can be a lot of data) up front so you can use the synchronous calls latter and only have to deal with one promise-based call at start up.

So the upshot is, this is not a bug, but the way MathJax works.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/924894D7-CBDB-40EE-978D-8D85FF746B04%40cabri.com.

Paul Libbrecht

unread,
Jun 23, 2025, 2:44:47 PMJun 23
to mathja...@googlegroups.com
Thank you David,

On 23 Jun 2025, at 20:39, Davide Cervone wrote:
> So the upshot is, this is not a bug, but the way MathJax works.

Cool thing. Thanks. I suggest to enhance the error message then.

E.g.

“MathJax would need to asynchronously load resources to render this fragment. Please call and await the promisified version or handle the asynchronity differently.”

Paul

Davide Cervone

unread,
Jun 24, 2025, 11:39:07 AMJun 24
to mathja...@googlegroups.com
Paul:

The "MathJax retry" error was intended to be internal communication among the various pieces of MathJax, and not something that users were supposed to see. Of course, when the wrong function is called, you do see it, so I suppose something more expressive would be useful.

The v4 documentation (which I'm currently working on and is nearly complete) includes a section on the "MathJax retry" error and how to deal with it.

Davide
> --
> You received this message because you are subscribed to the Google Groups "MathJax Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/mathjax-users/3E456136-2745-4CBE-BE41-9353D6ABEDB3%40cabri.com.
>

Reply all
Reply to author
Forward
0 new messages