CoffeeVampir3/Graphify

Null reference node not handled gracefuly

MPozek opened this issue · 1 comments

Steps to reproduce:

  1. Create a new graph blueprint class
  2. Create a root node for the blueprint, but don't keep it in a file named after the node (so unity can't serialize the reference)
  3. Create an instance of the graph
  4. Open the graph editor

Nodes list will have a serialized null node and will throw a null reference exception once on first open, and again each time it's opened. Other fields in the graph seem to maybe also not be initialized (didn't dive too deep into the error)

Unity version: 2020.3.2f1
Graphify version: 5.1.4
log.txt

This is indeed a bug, I was able to trivially reproduce it with the steps you provided.

There's two dimensions to this problem;

  1. Local graph data did not account for the possibility of a deleted node.
  2. Graphs with deleted nodes will cause runtime errors as the graph is no longer valid.

I have pushed a fix for issue (1) as of 5.1.6 see commit #61 which includes the following fixes for change tracking, which is run when a graph blueprint is opened or refreshed:

  1. Change Tracking now correctly checks for null
  2. If a null is detected, the editor model and runtime model remove the node.
  3. All links referencing a null node are also pruned as expected during this phase.

This will leave the graph in a completely stable state, as if the node type had never existed to begin with. Let me know if you run into further trouble.

Moving on to issue 2, at the moment, I do not see any meaningful way of correcting issue 2 as this essentially requires manually intervention per-graph to solve and cannot be corrected automatically. The next best thing might be to simply display an error message and an asset link for each effected graph which was invalidated by the deletion. This would require a new system which would track recompilations and perform an analysis, I'm not convinced that such a feature is neccesary at this time but I'll leave this thread open for discussion on the topic.

In addition, change tracking had some robustness problems that I've taken a moment to correct here. Now, any and all changes made will reflect when a graph is opened. See #62

Cheers,
Z.