Skip to content

Blazor.GraphEditor Not Working in Blazor Server / Blazor Hybrid Setup #1

@rcapil

Description

@rcapil

The library does not work out-of-the-box when used in a Blazor Server / Blazor Hybrid setup. In our use case, we're using it in a Blazor Hybrid setup and we need it to be thread safe and have internal component calls to use InvokeAsync(). We pulled in the project into our solution and made this tweak to get it working:

// GraphEditor.razor
<CascadingValue Value="callbackContext">
    <SVGEditor @ref=SVGEditor
               Input=@Input
               InputUpdated="(string s) => { Input = s; InvokeAsync(()=> StateHasChanged());}" // Wrapped in InvokeAsync
               SupportedElements=SupportedElements
               DisableContextMenu=true />
</CascadingValue>

We were able to get the sample code from Index.razor working in our Blazor Hybrid setup but it crashes after some time and we get this error:

System.InvalidOperationException: 'Collection was modified; enumeration operation may not execute.'

That happens on Node.cs class line 65:

 public override string StateRepresentation => base.StateRepresentation + Stroke + R.ToString() + (Image ?? "");

Any ideas as to what is happening here?

Would you be able to make enhancements to allow this library to work with a Server/Hybrid setup? If not, what other tweaks would we need to make to get passed the error above?

We also notice the visualization and animation is slower when in the context of a Server/Hybrid setup, is this due to the nature of the configuration that it requires constant server updates?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions