Skip to content

MathJax 4.0.0 + CHTML rendering + lazy load lays out incorrectly on macOS 14 #3444

@bthomale

Description

@bthomale

Issue Summary

I've discovered a layout bug with the MathJax CHTML rendering in MathJax 4.0.0.

On macOS 14.x in WKWebView/Safari, if you load mathjax 4.0.0 in CHTML mode using lazy loading, things don't load correctly. It looks like it maybe isn't reserving enough space for things, but I'm not quite sure. The math loads in tiny boxes.

I also put together a simple demo xhtml file to illustrate this.

With lazy load off, it loads fine. With svg mode instead of chtml, it also works fine.

If you open mathml-mj4.0.0-lazy.xhtml in Safari on macOS 14, you'll see the bug. I've tested macOS 12, 13, and 15 and it works fine on all of these. If you open mathml-mj3.2.2-lazy.xhtml you'll see that mathjax 3.2.2 doesn't have the bug.

With the simple demo I put together, all you see are the lines.

We're noticing this bug when we try to use MathJax 4.0.0 in VitalSource Bookshelf (which uses lazy loading). When we run on macOS 14, things don't load correctly. What I'm seeing in Bookshelf is maybe a little different but I imagine it's the same bug? It only loads a tiny tile of the content.

Steps to Reproduce:

  1. On a macOS 14.x system, open the attached files "mathml-mj3.2.2-lazy.xhtml" and "mathml-mj4.0.0-lazy.xhtml" from the file system in Safari. They're essentially the same, except one is pinned to version 3.2.2 and the other is pinned to 4.0.0.

Expected behavior: They should look the same.

Actual behavior: They're different. The 4.0.0 rendering seems to just be lines and not text.

Within our app, sometimes we also see the text rendering into tiny boxes on 4.0.0, but only on macOS 14.

Turning off lazy-load fixes it. Switching to SVG rendering fixes it.

I tested macOS 12, 13, 14, and 15 - and of those, it only happens on macOS 14.

Technical details:

  • MathJax Version: 3.2
  • Client OS: MacOS 14.6.1. (We've seen it with other patch versions of 14, too - every one I've tested)
  • Browser: Safari 17.6

I am using the following MathJax configuration:

      window.MathJax = {
        startup: {
          ready: function () {
            MathJax.startup.defaultReady();
            MathJax.startup.promise.then(function () {
              if (console && console.log) console.log("MJ4 typeset complete");
            });
          }
        },
        mml: { parseAs: 'xml' },
        loader: { load: ['ui/lazy'] }
      };

and loading MathJax via

    </script>

    <!-- MathJax 4.0.0 — MathML input, CHTML output -->
    <script id="MathJax-script" type="text/javascript"
            src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0/mml-chtml.js"
            defer="defer"></script>

Supporting information:

See attached for screenshots and the xhtml examples you can open in Safari

MJ-4.0.0-lazy-load-bug.zip

. Note that there are screenshots from our app as well, with and without the bug, to show how it manifests there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AcceptedIssue has been reproduced by MathJax teamCode ExampleContains an illustrative code example, solution, or work-aroundMergedMerged into develop branchv4

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions