Forum Bugs

Prince 8.1 r4 takes much longer on Javascript than 8.0

I have a HTML file that Prince 8.0 is nicely able to convert to PDF. In order to see whether a particular error message issued by Prince for which I have no explanation was a bug in Prince-XML, I upgraded to 8.1 r4 (on Windows).

The error message is gone, but running the scripts took 7.5 minutes with version 8.1 r4 for an HTML input file that took 1..2 seconds with version 8.0. The HTML file has CSS and an ~800 line Javascript file embedded that uses functions like document.getElementById() or document.body.getElementsByTagName().

My questions related to this performance change are:
-> Is this behavior already known (e.g. particular functions that take longer) ?
-> Is there anything I can do about it by recoding the Javascript file ?

By the way, the reason I could not find an explanation for the error message issued by version 8.0 was that the line it pointed to was an empty line between a line with the closing brace "}" of an if, and a line with the "else {" following it.

The error message issued by 8.0 is:
prince: dsp1033/dsp1033_1.1.0a.html:778: error: TypeError: undefined value is not an object

When converting line ends in the HTML file to CRLF, the displayed line number changed to 1555, but was still about 10 lines off of the real location (which I found by iteratively inserting and deleting empty lines to see whether the displayed line number changes).

So besides the question about the performance, my other questions related to the line number reported in error messages are:
-> At what level is Prince counting the lines used for reporting errors, is it exactly the HTML file as provided to Prince, or an internal file after some processing has happened (that might influence the line counting)?
-> In an HTML file with mixed LF, CR, CRLF line ends, which of those increment the line counter by how much ?

The big slowdown is because getElementsByTagName returns a live list in 8.1, while in 8.0 it incorrectly returned a static list that would not change when the document changed. We plan to fix the slowdown in 9.0, along with other JavaScript improvements, like better error handling. :)

Your document sounds interesting, would you be able to post a link to it, or email it to me ( so we can do some performance profiling with new Prince builds? Hopefully we can get that time down to something more reasonable.
Prince 9 is now available, and we have sped up getElementsByTagName considerably. Hopefully the performance should be acceptable now! :)