magjac / d3-graphviz

Graphviz DOT rendering and animated transitions using D3
BSD 3-Clause "New" or "Revised" License
1.67k stars 103 forks source link

Doesn't work after the second time I launch my browser #204

Closed tdashworth closed 2 years ago

tdashworth commented 2 years ago

Hi,

I am using this library within a .NetCore Blazor WASM application. I have the following scripts loaded:

    <script src="//d3js.org/d3.v5.min.js"></script>
    <script src="https://unpkg.com/@hpcc-js/wasm@0.3.11/dist/index.min.js"></script>
    <script src="https://unpkg.com/d3-graphviz@3.0.5/build/d3-graphviz.js"></script>

And this is the code I run every time the dot code or engine changes:

d3
        .select(element)
        .graphviz({ useWorker: true })
        .engine(engine)
        .dot(dot, () => console.log("Dot processed"))
        .render(() => console.log("Render complete"));

I am loading a big graph (62 vertices and 85 edges) which works the first time I debug the app via Visual Studio on a particular browser (when I changed browser it worked the first launch) but every restart after that the dot callback is never run.

Any ideas would really help! Thanks

magjac commented 2 years ago

Does that code run at all the second time? If so, try using .logEvents(true) to debug what d3-graphviz does.

tdashworth commented 2 years ago

Thanks for the quick reply. Please see the below logs:

Rendering started.
Event  1 start                  1     0
layoutStart            6     6

It was still like this after 5 minutes...

tdashworth commented 2 years ago

It's also worth noting that when it does load (in a new browser) I can modify and render the graph without a problem.

tdashworth commented 2 years ago

This is a successful run:

Rendering started.
Event  1 start                  1     0
Event  2 layoutStart            1     1
Event  0 initEnd               86 
Event  3 layoutEnd           1355  1442
Event  4 dataExtractEnd        19  1461
Event  5 dataProcessPass1End    7  1468
Event  6 dataProcessPass2End    3  1471
Event  7 dataProcessEnd         1  1472 prepare                    30
Dot processed
Event  8 renderStart            0  1472
Event  9 renderEnd             24  1496
Event 13 end                    1  1497
Render complete

I've now learnt clearing the cache and hard reloading does fix the issue. image

tdashworth commented 2 years ago

I have always experimented with disabling the service worker and the use of worker (useWorker: false) but neither resolved the issue.

tdashworth commented 2 years ago

This only seems to be an issue with debugging with Visual Studio. Running dotnet run has no issues.