Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Undefined cause of an exception (Read 4098 times)
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Undefined cause of an exception
Jun 12th, 2020 at 11:40am
Print Post  
Hello,
I'm starting to be desperate because I'm facing an exception that I can't find a cause for. It is so non-deterministic that I can't even provide you an example. From what I found this exception is somehow related to diagram links, maybe routing of links. What I got is this stack trace:

System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'

This exception was originally thrown at this call stack:
    A.QV.NR(System.Windows.Rect, MindFusion.Diagramming.Wpf.DiagramLink, int, int, MindFusion.Diagramming.Wpf.DiagramItemCollection)
    A.QV.RR(int, int, System.Windows.Rect, MindFusion.Diagramming.Wpf.DiagramLink, MindFusion.Diagramming.Wpf.DiagramItemCollection)
    MindFusion.Diagramming.Wpf.DiagramLink.IH(MindFusion.Diagramming.Wpf.ConnectionP
oint, System.Windows.Point, MindFusion.Diagramming.Wpf.ConnectionPoint, System.Windows.Point, bool, MindFusion.Diagramming.Wpf.DiagramItemCollection, A.QV)
    MindFusion.Diagramming.Wpf.DiagramLink.LV(bool, MindFusion.Diagramming.Wpf.ConnectionPoint, MindFusion.Diagramming.Wpf.ConnectionPoint, bool, MindFusion.Diagramming.Wpf.DiagramItemCollection)
    MindFusion.Diagramming.Wpf.DiagramLink.LV()
    MindFusion.Diagramming.Wpf.DiagramLink.Origin.set(MindFusion.Diagramming.Wpf.Dia
gramNode)
   

This is thrown when I set a node from Diagram nodes as an origin of a link. A funny thing is when I have two graphs and I open the first one that is without issue, then I can open the second one with no problem. But when I open second one as first, it crashes. If I remove all links everything is fine.

It really depends on nodes position because when I create a graph and apply layout then reopen it, it crashes. When I do the same but before reopening it I change one node's position, it is reopened successfully.

I'm just asking if you don't know what can be the cause or what to focus on.

Thanks for any advice
Jan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Undefined cause of an exception
Reply #1 - Jun 12th, 2020 at 12:29pm
Print Post  
Hi,

This maps to RoutingGrid.MarkObstacles method. From a quick reading, we think only this line has unchecked index, from code that applies CrossingCost -
Code
Select All
Point cp1 = link.ControlPoints[0];
 



and were able to reproduce like this -
Code
Select All
diagram.LinkRouter = new GridRouter();
diagram.RouteLinks = true;
diagram.LinkShape = LinkShape.Cascading;
var n1 = diagram.Factory.CreateShapeNode(10, 10, 100, 100);
var n2 = diagram.Factory.CreateShapeNode(110, 10, 100, 100);
var n3 = diagram.Factory.CreateShapeNode(210, 10, 100, 100);
var l1 = diagram.Factory.CreateDiagramLink(n1, n2);
var l2 = diagram.Factory.CreateDiagramLink(n1, n2);
l1.ControlPoints.Clear();
l2.Origin = n3; 



Any chance your diagram contains links with unpopulated points list while loading / building it? We'll review the code more thoroughly next week to see if there's anything else suspicious.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Re: Undefined cause of an exception
Reply #2 - Jun 15th, 2020 at 2:21pm
Print Post  
Hello,
Thanks for your reply. I checked all links and any of them doesn't have an empty collection of control points.

I tried to turn off automatic routing and all explicit callings of routing method (link.Route()) and it worked. Right after I applied the layout, it crashed. Also normally I use GridRouter, but I tried QuickRouter and it also worked. It's probably because I have a lot of containers and QuickRouter doesn't take containers as obstacles (afaik).

Any new ideas on what to check?
Thanks
Jan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Undefined cause of an exception
Reply #3 - Jun 16th, 2020 at 7:28am
Print Post  
Hi,

This build adds some logging to GridRouter -
https://mindfusion.eu/_temp/gridrouter_log.zip

Please call Diagram.EnableLogging("log.txt") and let us know what it says on last line after crashing.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Re: Undefined cause of an exception
Reply #4 - Jun 16th, 2020 at 10:08am
Print Post  
Hi,
here are few last lines of the log file when it crashed.

...
marking node interior as obstacle
applying node vicinity cost
marking container boundaries as obstacle
applying node vicinity cost
marking node interior as obstacle
applying node vicinity cost
marking node interior as obstacle
applying node vicinity cost
marking node interior as obstacle
applying node vicinity cost
marking container boundaries as obstacle


Then I tried to set ContainerNode Obstacle property to false and it worked.

Jan

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Undefined cause of an exception
Reply #5 - Jun 16th, 2020 at 11:33am
Print Post  
Hi,

Any chance this container has a negative Width or Height set?

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Undefined cause of an exception
Reply #6 - Jun 16th, 2020 at 11:49am
Print Post  
Our developer thinks found some logic error, please try new build here -
https://mindfusion.eu/_temp/gridrouter_log.zip

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Re: Undefined cause of an exception
Reply #7 - Jun 17th, 2020 at 7:04am
Print Post  
Hi,
I can't find any container with a negative width or height. But I looked at what I do with containers during graph building and I found out that immediately after I set bounds to a node I call UpdateBounds on node's container if any. I played with it for a while and when I call UpdateBounds only if a container is already loaded then it works. So maybe I do this operation too soon and it leads to the exception, but I still don't know what specifically is the cause, because it seems that is has no effect on bounds of the container at this moment.
So ...
this works:
Code
Select All
ContainerNode container = ContainerNode.GetContainer(AssociatedObject);

if(container?.IsLoaded == true)
    container.UpdateBounds();
 



this doesn't work:
Code
Select All
ContainerNode container = ContainerNode.GetContainer(AssociatedObject);
container?.UpdateBounds();
 



Jan

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Undefined cause of an exception
Reply #8 - Jun 17th, 2020 at 7:12am
Print Post  
Hi,

Does it still crash with new build from yesterday?

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Re: Undefined cause of an exception
Reply #9 - Jun 17th, 2020 at 9:58am
Print Post  
Ops, sorry I didn't notice you sent me a version to try. Anyway, I tried it and it works! Can you tell me what was the issue? Am I doing something unexpected in my codes and should avoid it?

Thanks
Jan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Undefined cause of an exception
Reply #10 - Jun 17th, 2020 at 10:17am
Print Post  
It's our bad, you've discovered 20-years old bug in GridRouter since our ActiveX days Wink If not negative width / height, we think it might be happening if initial width or height is smaller than router's GridSize, and the node is placed on the boundary of current routing area.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Re: Undefined cause of an exception
Reply #11 - Jun 17th, 2020 at 10:58am
Print Post  
Nice, understand. Thank you again.

Have a nice day
Jan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint