Unhandled mathjax loading related error in Viewer

Bug #1919033 reported by Georg
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released

Bug Description

The following error occurs all the time when viewing mathjax-heavy epub files in the Calibre E-book viewer, rendering it unusable:

calibre, version 5.13.0
ERROR: Unhandled error: Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.<br><span style="font-size:smaller">Error at userscript:viewer.js:26521:27</span>

Traceback (most recent call last):
    at HTMLHtmlElement.ρσ_anonfunc (userscript:viewer.js:22611:25)
    at IframeBoss.content_loaded_stage2 (userscript:viewer.js:26521:27)
TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.

Steps to reproduce:
1. Open the attached minimal "mathjaxtest.epub" in the Viewer.
2. Use the arrow keys or scrolling to navigate to the end of the book and back.
3. Repeat until error is thrown (normally 5-10 times).

One might see "failed to load: https://cdn.mathjax.org/mathjax/contrib/a11y/accessibility-meny.js" sometime before the error is thrown. Occurs both in Pages and Flow mode and with both epub 2 and epub 3 files. If the math is removed all is fine. This bug does not occur in Safari on iOS 14.4 when using the Calibre 5.13 content server.

I'm on macOS 10.15.7.

Revision history for this message
Georg (geo1481) wrote :
Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1919033

That's because your math book includes its own copy of mathjax, that is
expecting to run in a browser. Dont do that. calibre can render maths by
itself using its own bundled mathjax. For example, see

 status invalid

Changed in calibre:
status: New → Invalid
Revision history for this message
Georg (geo1481) wrote :

Thanks, that seems reasonable; however, removing the line where the external mathjax is loaded does not resolve this issue.

I did some more testing: The epub file provided in the linked manual section works without problems. This seems to be since that epub only consists of a single html file. Once I add some div tags into its html source, which causes Calibre to split it into several html files upon conversion to epub, the bug starts to happen also here. You can try it yourself with the attached epub.

As I understand it the Calibre viewer reloads Mathjax every time it has to load a new html file, and if one tries to navigate in the viewer before the Mathjax is loaded this unhandled exception error is thrown. This occurs too often to make the viewer usable in my experience.

Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: Invalid → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.