Page MenuHome

Group output node `is_linked` attribute is False during linking process
Confirmed, NormalPublicKNOWN ISSUE

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits

Blender Version
Broken: version: 2.91.0 Beta, branch: master, commit date: 2020-10-28 18:06, hash: rB911f9e00d13c

Short description of error
When a node is linking update method of its tree is calling. In this method sockets which was connected has status 'is_linked' as True except group outputs nodes. I would expect that sockets of those nodes also would have True in is_linked attribute.

Exact steps for others to reproduce the error

  • Open the file
  • run the script
  • after having made the links, the update callback will report 'is_linked' as False for the Group output node

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Needs Information from User.Nov 2 2020, 10:51 AM

Could you share an example snippet (or point at an Addon that uses this)?
How do you make Nodegroups work in custom nodetrees? (I always thought these are not supported?)

Ah, its Sverchock.

Would still be good to have this isolated (or at least pointed at the exact implementation in Sverchock - since I think this is not standard in custom nodetrees)

I have made the script. Just run it in text editor.

Don't know, node groups just works. Not everything is convenient (like this issue) but in general I can live with it. There is thread of making official supporting of group nodes.
https://developer.blender.org/T80827

There is link to the addon but it will be difficult to test it.
https://github.com/nortikin/sverchok/blob/83a815be6060afca44b51678fb7381f7f22bbceb/core/node_group.py#L76-L78

Philipp Oeser (lichtwerk) changed the task status from Needs Information from User to Confirmed.Nov 2 2020, 12:47 PM
Philipp Oeser (lichtwerk) changed the subtype of this task from "Report" to "Bug".

Can confirm on first linkage.
If you do the same thing again, it'll be correct for me though.

In any case, this sounds like a bug.

If you do the same thing again, it'll be correct for me though.

I think it's because the problem is only with virtual sockets. When the socket is connected second time it is not Virtual anymore.
https://docs.blender.org/api/current/bpy.types.NodeSocketVirtual.html

Jacques Lucke (JacquesLucke) changed the subtype of this task from "Bug" to "Known Issue".Nov 3 2020, 2:44 PM

Unfortunately, the is_linked property is not very reliable in general... That Blender does not update the SOCK_IN_USE flag in sockets immediately when a socket is linked/unlinked. This flag is only updated in a batch operation in ntreeTagUsedSockets. The problem is that with Blender's data structure for node trees it is just very inefficient to actually check if a socket it linked or not (it requires looping over all links).

I classify this as a known issue, because deeper design changes are necessary to actually fix this in a good way.

The problem is that with Blender's data structure for node trees it is just very inefficient to actually check if a socket it linked or not (it requires looping over all links).

Why can't the is_linked attribute status be updated with creating new link? If link was created it is obvious that linked sockets should have True status. Don't see why it should take O(n) of links.

Probably this issue about the same problem.
https://developer.blender.org/T82390

I totally understand your point. We could just update the is_linked attribute immediately in some specific cases. The issue is, we create and remove links in quite a few places. So while we could change it in one place, quite a bit more refactoring is needed to fix this in all cases where new links are created. Furthermore, things become more tricky when we want to disable is_linked when a link is removed, because that definitely takes O(n) in the current data structure.

Personally, I'd rather not have a partial fix that only works in some cases. Fixing this correctly takes more time and I hope I'll get to it in the future. For now this is a known issue, unfortunately.

Realistically speaking, I recommend you to just not rely on the fact that is_linked is accurate all the time. If you need accurate information, you have to iterate over the links yourself. That is what I've been doing for years... It's a bit sad, but that is how it is and will be for some time.

Note, saying that this is a "Known Issue" means that we acknowledge that this is a bug, but it does not have high enough priority to be fixed soon, given the development capacity we have.

Don't know but half solution of the problem does not look too bad. It will make tree model more accurate so why not doing this?
It would solve several problems entirely (including the issue of this topic) which I encountered:

  • When reroute is added I have to replace its socket by my one.
  • There are nodes which socket types dependent on socket types to which they are connected.
  • During creating node groups from selected nodes they should be copied into another node tree and extra linking should be done. I Did not check this variant but I guess it should share the same problem.

My another hope is to use timers. It should create break between tree udpate events and evaluation of custom update system. It looks like that in this gap Blender is recalculating tree model and when timer is running all attributes in tree are correct.

My another hope is to use timers. It should create break between tree udpate events and evaluation of custom update system. It looks like that in this gap Blender is recalculating tree model and when timer is running all attributes in tree are correct.

If nothing has changed since I last looked at it, this is the approach used by Animation Nodes to work around these issues. It also gives you the ability to do "global socket type inferencing", which is more flexible than when every socket just looks at its immediately connected socket.