Skip to content

Dynamically adding new nodes causes exceptions #466

@cwendjustus

Description

@cwendjustus

I've noticed adding/removing nodes/ports can cause exceptions due to race conditions. There are three cases I have documented (of which one is the Navigator Widget) but everything which makes use of the changed collections and is triggered by a re-render can cause the same exceptions to be thrown.

Note: these are lines copied from a debugging session

NavigatorWidget.cs
	foreach (... in BlazorDiagram.Nodes ...) EXCEPTION (collection was modified)
DiagramCanvas.cs
	foreach (... in BlazorDiagram.OrderedSelectables) EXCEPTION (collection was modified)
JSRuntimeExtensions.cs
	return await Microsoft.JSInterop.JSRuntimeExtensions.InvokeAsync<Rectangle>(jsRuntime, "ZBlazorDiagrams.getBoundingClientRect", new object[1] { element }); EXCEPTION (some object is null)

I think the cause is the automatic re-rendering on diagram changes while modifying collections (the nodes and/or links).
My first attempt at resolving this was setting both Diagram.SuspendRefresh and Diagram.SuspendSorting to false but this does not solve the issue.

Has anyone else experienced this issue or have suggestions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions