mathjax / MathJax-node

MathJax for Node
Apache License 2.0
614 stars 96 forks source link

Crashing when calling to `mjAPI.start()` or `mjAPI.typeset(...)` #408

Closed TalAmuyal closed 6 years ago

TalAmuyal commented 6 years ago

When calling either mjAPI.start() or mjAPI.typeset(""), the app crashes. Running in an Electron app. Copy-pasted the example from the README. Node version: v8.11.1 MathJax-node version: 2.1.0

dpvc commented 6 years ago

You have not provided sufficient information to diagnose your problem. For example, the actual error message produced might help. Note that mjAPI.typeset("") is not the correct syntax (you should pass an object not a string to the typeset() command).

TalAmuyal commented 6 years ago

You are right about that, I copied the code to this issue badly. But even so, calling start() is enough for it to reproduce.

What I see is that the browser window becomes white and unresponsive and there is a message in the DevTools: DevTools was disconnected from the page. Once page is reloaded DevTools will automatically reconnect..

I see no relevant message in the console or in the terminal.

TalAmuyal commented 6 years ago

Also, couldn't catch it with try {} catch (err) {}.

dpvc commented 6 years ago

Have you tried running in another browser?

Googling the error message suggests that infinite loops may cause this problem. There was a recent issue where calling start() twice in a row could cause a crash that has been patched the develop branch. Can you try the develop version and see if that helps?

TalAmuyal commented 6 years ago

Tried the latest master, didn't help :(

And I don't think it is called twice (it is in global scope, and I've added console.error calls before and after to be sure).

Any ideas of things to try?

dpvc commented 6 years ago

It is develop not master that I suggested. The changes haven't been merged into master yet.

TalAmuyal commented 6 years ago

Just tried develop (4f5c3a6dca602482e7b954cc5a015960605a61e8) with the same result.

TalAmuyal commented 6 years ago

Made a more complete repro:

git clone https://github.com/onivim/oni.git
cd oni
git checkout v0.3.4
yarn add mathjax-node
yarn run build
yarn start # After waiting about a minute, the GUI should be active and good to go
# Alt-tab (to get back to the terminal)
Ctrl-C # To terminate the app
# Now that it runs fine, the test can begin:
echo "" >> extensions/oni-plugin-markdown-preview/lib/index.js
echo "const a = require(\"mathjax-node\")" >> extensions/oni-plugin-markdown-preview/lib/index.js
echo "a.start()" >> extensions/oni-plugin-markdown-preview/lib/index.js
yarn start # App loads and after an additional second or 2, the issue appears

Notes:

TalAmuyal commented 6 years ago

Hi, just an update.

Each of the following snippets crushes the app:

document.head.appendChild(script);

window.addEventListener("error",function (event) {AddError("Error: "+event.error.stack)});

content.innerHTML = '<script type="math/tex">x</script>' +
                      '<script type="math/asciimath">x</script>' +
                      '<script type="math/mml"><math><mi>x</mi></math></script>';

As for me, I moved to mathjax-electron. Seems that it has some changes that solves my problem(s).

Anyway, thanks for the time!