sverweij / state-machine-cat

write beautiful state charts :scream_cat:
https://state-machine-cat.js.org
MIT License
811 stars 45 forks source link

Ability to pass options to the underlying engine to prevent "Cannot enlarge memory arrays"? #27

Closed rodinhart closed 6 years ago

rodinhart commented 6 years ago

I am trying to visualise a fairly sizable statechart (maybe 50 states, with 7 levels deep nesting), but get an error when going beyond level 5.

Expected Behavior

Expect the SVG to be produced.

Current Behavior

abort("Cannot enlarge memory arrays. Either
(1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216,
(2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations,
(3) set Module.TOTAL_MEMORY to a higher value before the program runs, or
(4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 "). 
Build with -s ASSERTIONS=1 for more info.

Possible Solution

Increase allocated memory, or provide more detailed error logging why it runs out? Perhaps a small tweak to the statechart will prevent the engine from choking?

Steps to Reproduce (for bugs)

Context

I'm just trying to find a good visualizer for our statechart, most importantly one that is stable (in its layout).

Your Environment

sverweij commented 6 years ago

hi @rodinhart - below the waterline state-machine-cat uses viz.js (which is graphviz, compiled to javascript) by default for generate the svg. it's viz.js that emits this error message.

I agree b.t.w. about the (lack of) clarity of the error message - I'll see if I can at least put some context to it before passing it on to output.

=> I'm b.t.w. very interested in sizeable (and big / humongous) charts to include them in my automated tests. I'll understand if you can't share your state machine description - but if you can it would be helpful (and maybe I can tweak something in the dot state-machine-cat generates so it does work when I have a real life sample...)

rodinhart commented 6 years ago

Hallo @sverweij , thank you for the extensive response! My response to your response in order:

I will try the different layouts and see how they do. The default dot is definitely the one that I'm after, as it seems the clearest, and closest to Harel's diagrams.

I will definitely try using graphviz directly, this will hopefully allow me to tweak a few things which would be perfect.

Re low memory replacement for graphviz: understood, I appreciate the difficulty of putting something appropriate in place.

Re new version of viz.js. Also understood, we've all been there.

Finally, I will try to get an anonymized version of the statechart to you for testing purposes.

Thanks again.

sverweij commented 6 years ago

FYI: I've made a minimal reproduction sample - it seems the nesting depth is quite memory intensive for the dot algorithm. fdp and osage handle it better. They also yield nicer looking diagrams (see below - for smaller/ less deeply nested diagrams this is not typically true...)

a {
    aa {
        aaa {
            aaaa {
                aaaaa {
                    aaaaaa {
                        aaaaaaa {
                            aaaaaaaa {
                                aaaaaaaaa => aaaaaaaab;
                                aaaaaaaaa => aaaaaaaac;
                                aaaaaaaac => aaaaaaaad;
                            }; 
                        };
                    };
                };
            };
        };
    };
};

osage

mrp-osage

fdp

mrp-fdp

dot

😬 mrp-dot

rodinhart commented 6 years ago

Brilliant!

_statemachine.txt

Both fdo and osaga manage to produce a chart, but in my case a lot of the transition go wildly across the diagram. Also, some transition meet not at the edge of a node, but somewhere in white-space. dot seems to be better suited (if we can get it to run).

I still want to try graphviz directly, just to see what happens.

rodinhart commented 6 years ago

graphviz works!

sverweij commented 6 years ago

thanks for the _statemachine.txt - helpfull!

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.