Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in SVG export of a GroupWorkflow's workflow #1793

Open
PathogenDavid opened this issue May 11, 2024 · 0 comments
Open

Crash in SVG export of a GroupWorkflow's workflow #1793

PathogenDavid opened this issue May 11, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@PathogenDavid
Copy link
Member

Found while writing the issue for #1792

I'm not 100% sure what conditions cause this, but I wanted to get this written down before I forgot.

  1. Follow all of the steps outlined in Replacing a node with a group workflow when it receives a visualizer mapping generates a bogus source node #1792
  2. Go to the GroupWorkflow tab
  3. Go to File > Export > Image...

Bonsai will crash with a NullReferenceException with the following stack trace:

>	SVG.dll!SvgNet.SvgFactory.LoadFromXML(System.Xml.XmlDocument doc, System.Xml.XmlElement el) Line 79	C#
 	Bonsai.Editor.dll!Bonsai.Editor.GraphView.SvgRendererFactory.TryGetIconRenderer(Bonsai.Editor.GraphModel.ElementIcon icon, out Bonsai.Editor.GraphView.SvgRenderer renderer) Line 675	C#
 	Bonsai.Editor.dll!Bonsai.Editor.GraphView.SvgRendererFactory.GetIconRenderer(Bonsai.Editor.GraphModel.GraphNode node) Line 627	C#
 	Bonsai.Editor.dll!Bonsai.Editor.GraphView.GraphViewControl.DrawNode(SvgNet.Interfaces.IGraphics graphics, Bonsai.Editor.GraphView.GraphViewControl.LayoutNode layout, System.Drawing.Size offset, System.Drawing.SolidBrush selection, System.Drawing.SolidBrush fill, System.Drawing.Pen stroke, System.Drawing.Color currentColor, System.Drawing.Color? cursor, bool hot, System.Drawing.Font vectorFont) Line 1099	C#
 	Bonsai.Editor.dll!Bonsai.Editor.GraphView.GraphViewControl.canvas_Paint(object sender, System.Windows.Forms.PaintEventArgs e) Line 1247	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.OnPaint(System.Windows.Forms.PaintEventArgs e)	Unknown
 	<snipped>

Within SvgNet, the crash happens here: SvgFactory.LoadFromXml specifically because _elementNameDictionary["WorkflowBuilder"] is null (or rather it's missing from the XML document.)

Something seemingly nonsensical is happening. Looking up one level at TryGetIconRenderer, the icon being "opened" is ReplaceNodeWithGroupWorkflowIssue-GroupWorkflow.svg (which is the file I was trying to save.) At the time of crashing this file contains what appears to be my GroupWorkflow saved as a Bonsai workflow:

<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.1+b39a77efc5e3aa0024017fe253bb3b1d4417bbcc"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns="https://bonsai-rx.org/2018/workflow">
  <Workflow>
    <Nodes>
      <Expression xsi:type="WorkflowInput">
        <Name>Source1</Name>
      </Expression>
      <Expression xsi:type="WorkflowOutput" />
    </Nodes>
    <Edges>
      <Edge From="0" To="1" Label="Source1" />
    </Edges>
  </Workflow>
</WorkflowBuilder>

No idea what's happening here, definitely need to look into it more.

@glopesdev glopesdev added the bug Something isn't working label May 11, 2024
@glopesdev glopesdev added this to the 2.9 milestone May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants