Race condition MathJax and Runestone

10 views
Skip to first unread message

Bradley Miller

unread,
Jul 8, 2022, 5:59:11 PM7/8/22
to PreTeXt development
There are a few places where we have discovered a race condition between Runestone and MathJax.  Where Math ends up not rendered in a multiple choice and other areas.

I think the solution is to add this to the MathJax object created at the top of an HTML page.

  startup: {
    pageReady() {
      return MathJax.startup.defaultPageReady().then(function () {
      console.log("in ready function");
      $(document).trigger("runestone:mathjax-ready");
      }
    )}
},

This gives me an event to wait for to ensure that when I queue up a mathjax render mathjax is fully loaded.

This looks like it works, but I'm not MathJax wizard, so if someone has a more foolproof way I'm happy to hear about it.

Brad

Sean Fitzpatrick

unread,
Jul 8, 2022, 6:49:06 PM7/8/22
to prete...@googlegroups.com
I tried dropping this in without success, but it's entirely possible that I put it in the wrong place.
What's really odd: the page where the math won't render for me when I push it to github.io, *does* render just fine when I open the same file locally! (using Chrome in both cases)

Bradley Miller

unread,
Jul 8, 2022, 9:56:53 PM7/8/22
to prete...@googlegroups.com
Sean,

It will not work without a new release of the Runestone Components.  I’ll do that tomorrow, and then give Rob the new information so that PreTeXt books can build with this new release.

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy
Blog: A Reputable Journal
--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-dev/53864396-bae8-2493-37de-2f002719dc02%40gmail.com.

Bradley Miller

unread,
Jul 16, 2022, 2:40:06 PM7/16/22
to PreTeXt development
Rob,

If you can add this to the appropriate place then we can test with my new Javascript.

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy
Blog: A Reputable Journal
--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.

Rob Beezer

unread,
Jul 16, 2022, 3:51:43 PM7/16/22
to prete...@googlegroups.com
OK, addition here and PR #1790 are live. Let's get this scoped out *today* if
we can - next few days will be harder for quick reactions to any problems.

Tested on sample article and sample book (with lots o' Runestone Components).

I see message in the console early, from the page, and then "pretext.js" reports
a MathJax version next.

Math seems unharmed.

I could not provoke bad math with new RS Services and before adding startup
hook. We'll have to have Sean F reload 100 times.

Rebuilding website samples now, will take up to 20 minutes.

Rob


On 7/16/22 11:39, Bradley Miller wrote:
> Rob,
>
> If you can add this to the appropriate place then we can test with my new
> Javascript.
>
> Brad
>
> *Bradley Miller, PhD*
> Professor Emeritus Computer Science
> Luther College
> Founder, Runestone Academy <https://runestone.academy>
> Blog: A Reputable Journal <http://reputablejournal.com>
> On Jul 8, 2022, 4:59 PM -0500, Bradley Miller <br...@runestone.academy>, wrote:
>> There are a few places where we have discovered a race condition between
>> Runestone and MathJax.  Where Math ends up not rendered in a multiple choice
>> and other areas.
>>
>> I think the solution is to add this to the MathJax object created at the top
>> of an HTML page.
>>
>>   startup: {
>>     pageReady() {
>>       return MathJax.startup.defaultPageReady().then(function () {
>>       console.log("in ready function");
>>       $(document).trigger("runestone:mathjax-ready");
>>       }
>>     )}
>> },
>>
>> This gives me an event to wait for to ensure that when I queue up a mathjax
>> render mathjax is fully loaded.
>>
>> This looks like it works, but I'm not MathJax wizard, so if someone has a more
>> foolproof way I'm happy to hear about it.
>>
>> Brad
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PreTeXt development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pretext-dev...@googlegroups.com
>> <mailto:pretext-dev...@googlegroups.com>.
>> <https://groups.google.com/d/msgid/pretext-dev/1cfe662b-2d96-48a3-8ed2-a1052b42de9an%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com
> <mailto:pretext-dev...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-dev/45a8958f-cebf-4f5b-95b5-81a19b74693d%40Spark
> <https://groups.google.com/d/msgid/pretext-dev/45a8958f-cebf-4f5b-95b5-81a19b74693d%40Spark?utm_medium=email&utm_source=footer>.

Bradley Miller

unread,
Jul 16, 2022, 4:10:24 PM7/16/22
to prete...@googlegroups.com
I can make it happen about every 3rd try in the sample book using runestone 6.2.1.  Once the rebuilds are done we will see what happens.

You must have recently added the mathematical multiple choice?  I don’t remember it before.


Brad

Bradley Miller, PhD

Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-dev/4bf12a3c-32d6-299b-643d-e9fd80b73c53%40ups.edu.

Rob Beezer

unread,
Jul 16, 2022, 4:15:54 PM7/16/22
to prete...@googlegroups.com
On 7/16/22 13:10, Bradley Miller wrote:
> I can make it happen about every 3rd try in the sample book using runestone
> 6.2.1.  Once the rebuilds are done we will see what happens.

Look now.

> You must have recently added the mathematical multiple choice?  I don’t remember
> it before.

I don't think so. ;-) Only the vector spaces and bases problem was added after
the big push.

Rob

Bradley Miller

unread,
Jul 16, 2022, 4:45:24 PM7/16/22
to prete...@googlegroups.com
Unfortunately this does not seem a lot better.  I will have to continue to research

The event I trigger does’t seem to ever get noticed by my code… So, something else is going on here.

No reason to retreat from 6.3.0 as there are other good bug fixes in there too.


Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy
Blog: A Reputable Journal
--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.

Rob Beezer

unread,
Jul 16, 2022, 5:02:01 PM7/16/22
to prete...@googlegroups.com
OK, we'll keep 6.3.0 of course.

It doesn't seem the MJ change is hurting anything so you will see where you can experiment with that.

Bradley Miller

unread,
Jul 16, 2022, 5:18:52 PM7/16/22
to prete...@googlegroups.com
I have a branch now where I have reliably fixed it.   I could recreate the problem locally before and now I have not been able to recreate it once after many many refreshes… In any race condition there are at least two possible winners.  I had to consider more carefully what was going on when MathJax won the race.

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy
Blog: A Reputable Journal

Sean Fitzpatrick

unread,
Jul 20, 2022, 11:52:02 AM7/20/22
to PreTeXt development
Things are looking good for my book now as well. Thanks!

Only thing left not working for me is display math in Parsons blocks.
(If the solution is "don't use display math in a Parsons block", I'm all right with that.)

Reply all
Reply to author
Forward
0 new messages