viz-js
viz-js copied to clipboard
Large diagram fails on Chrome / Safari
I've checked with https://gist.github.com/mjpieters/29623e9585fd694cdcc5 and it crashed with Uncaught RangeError: Maximum call stack size exceeded. Maybe there is a place for optimizations.
Hi @mstefaniuk I have tested your super large graph in my local install of viz.js and no error. It generates a super large image. And not too slow either. Loving the viz.js, Well done @mdaines

@aquaalex Strange but maybe only little bit. Today I've repeated test on official viz.js demo site on Windows and it works both on Firefox and Chrome. Yesterday I've checked it on Firefox, Chrome and Safari on OS/X - last two returned error I mentioned. Maybe it's only a OS/X error? Or maybe it happens when viz.js is deployed within WebWorker?
@mstefaniuk maybe it is worth it looking at different versions of browsers? Not sure about the WebWorker issue, but that should be an easy test.
I've checked it just now and when launched on Chrome 47.0.2526.80 (64-bit) on OS/X I've received original error. The same on Safari 9.0.1 (11601.2.7.2).


Just for Info I have tested Viz.js on a few versions of Windows and Android and a few versions of browsers
O/S: Windows 8.1 Firefox 43 Google Chrome 47 Internet Explorer 11
Android 5.0 Google Chrome 47
Windows 7: Internet Explorer 9 Internet Explorer 8 - Javascript Error
Windows Server 2003 EE SP2: Firefox 25 Google Chrome 20 Internet Explorer 7 - Javascript Error
@mstefaniuk & @mdaines - It definitely seems to be an OSX issue, I wonder if anyone has tested it on any other Apple products.
Maybe the topic should be changed to: Large diagram fails on OSX(Apple)?
@aquaalex For sure there is one OS/X exception with Firefox. It looks rather as OS/X Webkit issue.
I was curious as to what was causing the overflow and it seems to be depth-first search graph algorithms in GraphViz like inter_tree_edge_search and dfs_range.

Recalling some of my related previous research, different browsers will have different maximum stack depths. And this will also depend on other factors such as stack frame size. Isolating it to a specific browser version or OS unfortunately won't help, as there doesn't seem to be a standard size that can be depended on, and a large enough input can always exceed it regardless. Sounds like this ticket can be closed in favor of opening a ticket with GraphViz to perhaps make the algorithms iterative or tail call (although I'm not sure Emscripten can do anything with tail call optimization.)
this issue was introduced in 1.8.0, you won't have this issue on site viz-js.com becuase it has 1.7.1 version installed
I'm closing this since I could get the graph to render in Safari using a build from the v3 branch. That branch is also substantially different from the version of Viz.js this issue would have appeared in -- it uses WebAssembly and a newer version of Graphviz.
However, the v3 version can still run into problems like this with larger graphs -- I found that I could get a RangeError: Maximum call stack size exceeded error in Node.js with a graph of 8000 nodes.
Maybe related? https://github.com/emscripten-core/emscripten/issues/13043