mermaid-js / mermaid-live-editor

Edit, preview and share mermaid charts/diagrams. New implementation of the live editor.
https://mermaid.live
MIT License
3.82k stars 574 forks source link

Out Of Memory issue when rendering certain cases of gantt chart #1474

Open benfernandes opened 1 week ago

benfernandes commented 1 week ago

Describe the bug I experience an OOM error when trying to render certain gantt charts.

I've provided a test case below. The key things to point out are

With this configuration, I think the rendering engine runs into an issue when it tries to create a gantt chart for a timespan this wide, with a tick on every day. It's too much for it to handle, so crashes.

To Reproduce I suggest doing this in a private window to avoid breaking your main mermaid.live

  1. Paste this into the live editor https://mermaid.live/:
    gantt
    tickInterval 1day
    Step A :2024-07-15, 3d
    Step B :220, 1d
  2. See that the editor/browser tab freezes
  3. Navigate to https://mermaid.live/ again
  4. See that the editor is once again frozen (this proves that the data was successfully stored into local storage - on trying to read and display, the browser freezes again)

Expected behavior The editor should not freeze - I should get some sort of error.

Screenshots image

Desktop (please complete the following information):

Additional context The main issue here is that I was editing something in the live editor, then it froze up leaving me unable to access my work. Because the tab was frozen whenever I went back to mermaid.live (due to the reloading from local storage), I was also unable to open up dev tools. To get my work back, I had to take the URL and reverse-engineer the compression by looking at the Mermaid source code. Ideally, users shouldn't have to do this. I suggest: