Sporadic [Math Processing Error] in Firefox and IE9

208 views
Skip to first unread message

Clay Harris

unread,
Apr 8, 2015, 1:40:17 PM4/8/15
to mathja...@googlegroups.com
Hi,


I'm running into sporadic math processing errors in Firefox and IE9.  So far I haven't seen it in other browsers (never in Chrome).  My app loads content, which often includes MathML, then typesets the parent element.  This works fine most of the time, but on occasion, particular equations throw the error.  I can't find anything wrong with the MathML, and it works subsequent loads of the same MathML data - I have to refresh the page to get it to re-occur.  I haven't been able to replicate in jsbin, but a rough approximation of the logic (and the exact MathML pulled from 'show math as -> original MathML') is located at: http://jsbin.com/bubuxariwe/1/.  In the app, it typesets as soon as it loads.  And it is always the last element / equation that throws the error.  This is happening on multiple devices, on multiple operating systems.  Is there anything I can do to further debug / diagnose / fix the issue?


Thanks,

Clay Harris

Clay Harris

unread,
Apr 8, 2015, 1:48:53 PM4/8/15
to mathja...@googlegroups.com
Quick follow-up - if I right click and select HTML-CSS as the renderer (which it already is) for the error, it renders it correctly.  Is there a way to check for errors and re-render if an error occurs?  Or should I just use the callback to check for errors via MathJax_Error class, and tell it to typeset again if there's an error?

Mark Doyle

unread,
Apr 9, 2015, 9:41:59 AM4/9/15
to mathja...@googlegroups.com
Hi,

We are seeing something similar, but see the problem in multiple browsers including Chrome. The error message we see is:

Error: Cannot read property 'w' of undefined

Selecting the HTML+CSS renderer doesn't seem to help in our case (at least in Chrome). We are using MathJax 2.5.1

Best,
Mark

On Wednesday, April 8, 2015 at 1:40:17 PM UTC-4, Clay Harris wrote:

Clay Harris

unread,
Apr 9, 2015, 9:46:39 AM4/9/15
to mathja...@googlegroups.com
Hi Mark, 

It sounds like in your case, there's a javascript error occurring somewhere.  I think I saw a similar issue posted in the group when I was researching my issue, so that may be of some help to you, though since the issue didn't match mine I don't recall whether they resolved it.



--
You received this message because you are subscribed to a topic in the Google Groups "MathJax Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mathjax-users/_WcT5QjFbo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Krautzberger

unread,
Apr 9, 2015, 10:30:01 AM4/9/15
to mathja...@googlegroups.com
Hi,

Is anyone able to provide a live sample that exhibits the problem? 

It probably helps to use the unpacked version of MathJax to debug to get more meaningful errors.

Thanks,
Peter.

--
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.

pa...@aps.org

unread,
Apr 9, 2015, 4:54:28 PM4/9/15
to mathja...@googlegroups.com
On Thursday, April 9, 2015 at 10:30:01 AM UTC-4, Peter Krautzberger wrote:
Is anyone able to provide a live sample that exhibits the problem? 

I'm trying to isolate an example but it's been difficult so far. It definitely is something either in combination with other resources on the page or after a sequence of rendering. I'm unable to replicate it if I extract the MathML for each equation that generates a "Math Processing Error" and render it on its own.

It probably helps to use the unpacked version of MathJax to debug to get more meaningful errors. 

We see the same issue using the unpacked version, the error message is always "Error: Cannot read property 'w' of undefined". Is there a setting somewhere to get MathJax to just throw these as JS exceptions so I could work through the stack trace in the browser console?

Thanks,
Paul

Davide P. Cervone

unread,
Apr 9, 2015, 6:37:55 PM4/9/15
to mathja...@googlegroups.com
My suspicion is that you are having synchronization problems between MathJax and GWT.  I don't know GWT at all, so can't really help with that, and the code you posted in your previous thread had most of its code minified, so it is pretty difficult to make sense of it.  Is it possible for you to generate an un-minified version?

One difference between your jsbin version and the GWT one is that the latter uses an iframe, and it appears that MathJax is running within the iframe.  The MathML seems to be loaded into the iframe, MathJax run, and then the results moved to the main document.  This is not really a use-case that MathJax supports, and there are several issues you have to be concerned about.  For example, MathJax will add styles to the iframe that would need to be copied to the main document, and may not be.

More importantly, I suspect that GWT may be moving the contents of the iframe before MathJax has finished processing.  That could account for the results you are getting with Firefox and IE:  MathJax first sets up spans for all the equations on the page, and then goes back and fills them in (there are performance reasons for that).  I suspect that GWT is copying the page in between those two phases, before MathJax has typeset the math.  The timing of when this occurs can depend on the browser, which is why it works in some and not others (it has to do with when the various signals for DOM content loaded and page load events occur, and those differ from browser to browser).

The [Math Processing Error] that you are getting may be for a similar reason.  For example, it could be that GWT is tearing down the DOM of the iframe while MathJax is still working on it, and so data that it needs is missing when it goes to create the final equation on the page, and so gets the processing error.  (The "w" from the message is likely to be part of bounding box data that MathJax stores attached to the elements in the page, so if they are being removed or altered while MathJax is working, that could cause the problem.)

I suspect that you need to coordinate the actions of MathJax with those of GWT.  For example, when you queue MathJax's Typeset action via 

MathJax.Hub.Queue(["Typeset",MathJax.Hub,element]);

the typesetting is not complete when the Queue function completes.  So the on click event that calls MathJax.Hub.Queue() returns before the typesetting is done.  GWT may think that that means it is time to copy of iframe to the main page, even though MathJax isn't done yet.  So you may need to do something more to tell GWT to wait longer before the page is ready.  Since I don't know GWT, I can't tell you what that is, but if there is some other way to signal GWT when things are ready, you might need to queue a second function that does that.

As for trapping the error, throwing the error outright would cause MathJax to stop running and not do any more typesetting, which is why that isn't done.  But there are several ways you can get at the error.  For debugging purposes, the error object for the last [Math Processing Error] is stored in MathJax.Hub.lastError, so you can use MathJax.Hub.lastError.stack to get the call stack for the error.

Alternatively, you can register message hook for those errors and have a callback called when one occurs.  E.g.,

<script type="text/x-mathjax-config">
MathJax.Hub.Register.MessageHook("Math Processing Error",function (message) {
   console.log(message[2].stack);  // message[2] is the error object
});
</script>

I don't think you will learn anything really from this, as I don't think it is a MathJax-specific issue, but a timing issue between MathJax and GWT.  But you might be able to look at the iframe DOM (e.g., console.log(document.body.innerHTML)) when the error occurs and see what is happening.

I hope that gives you something to try.

Davide


pa...@aps.org

unread,
Apr 10, 2015, 10:29:26 PM4/10/15
to mathja...@googlegroups.com, dp...@union.edu
Hi Davide,

Thanks for the info on setting up the message hook. I was able to get the stacktrace below for the problem we're experiencing. I'm hoping you might have some insight. We're not using GWT or using iframes and we manually queuing the calls to Typeset but it is possible there's an interaction with some other JS on the page. 

TypeError: Cannot read property 'w' of undefined
    at a.mo.Augment.HTMLbetterBreak (multiline.js?rev=2.5.1:19)
    at a.mbase.Augment.HTMLbetterBreak (multiline.js?rev=2.5.1:19)
    at a.mbase.Augment.HTMLbetterBreak (multiline.js?rev=2.5.1:19)
    at a.mbase.Augment.HTMLmultiline (multiline.js?rev=2.5.1:19)
    at MathJax.Hub.Register.StartupHook.g.mbase.Augment.toHTML (jax.js?rev=2.5.1:19)
    at MathJax.Hub.Register.StartupHook.g.math.Augment.toHTML (jax.js?rev=2.5.1:19)
    at b.Register.StartupHook.g.math.Augment.toHTML (TeX-AMS-MML_HTMLorMML.js?rev=2.5.1:56)
    at d.Augment.Translate (jax.js?rev=2.5.1:19)
    at Object.MathJax.Hub.processOutput (MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured:19)
    at Function.CALLBACK.execute (MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured:19)
Reply all
Reply to author
Forward
0 new messages