From ae18ba2a05dad1a4860f8a638318e4a0a5c6f52a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 21 May 2022 14:01:38 +1000 Subject: [PATCH] Switch editor to full MathJax package to fix broken autoloads Re: https://forums.ankiweb.net/t/anki-2-1-53-release-candidate/20122/2 Autoloads in MathJax are asynchronous, and the caller is expected to use asynchronous APIs when they are in use [1]. The editor uses the synchronous tex2svg(), which throws a "MathJax retry" error when an autoload package has not yet loaded. Attempting to use the package before it has loaded appears to break future invocations as well, so the package fails to work at all until a new webview is created. The following HTML will reproduce the issue when added to a single card in a new profile: ``` 6    Every combination of \boldsymbol{v}=(1,-2,1) and \boldsymbol{w}=(0,1,-1) has components that add to  _____.
``` Ideally we'd switch the MathJax rendering to be asynchronous, but that didn't work well when I tried it in #1862. For now I've just switched to the full package, which adds about 130KB to the final minified JS (2.76MB), and likely slows down editor loading somewhat. [1] https://github.com/mathjax/MathJax/issues/2557#issuecomment-727655089 --- ts/editable/mathjax.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/editable/mathjax.ts b/ts/editable/mathjax.ts index 6ef29cb57..55e23498d 100644 --- a/ts/editable/mathjax.ts +++ b/ts/editable/mathjax.ts @@ -5,7 +5,7 @@ @typescript-eslint/no-explicit-any: "off", */ -import "mathjax/es5/tex-svg"; +import "mathjax/es5/tex-svg-full"; import { mathIcon } from "./icons";