FlowCanvas Forums › Support › [Bug v3.2.1] Nodes Menu fails to populate on reflection nodes
Specs:
While updating our project from Unity 2020.3.x to Unity 2021.2.x, we’ve discovered that the Nodes Menu fails to populate when it’s opened (staying stuck on “Loading” and no nodes showing when searching). On a deeper look, I found that the hangup occurs in FlowGraphExtensions.cs:247 and commenting out menu = flowGraph.AppendAllReflectionNodesMenu(…. will allow the menu to populate (just…without reflection-based nodes).
Something locks up in FlowGraphExtensions.AppendTypeReflectionNodesMenu() on Unity 2021.2.0f1.
To reproduce this:
I’ve managed to narrow down to the call that’s hanging up.
In ReflectionTools.cs:891, the RTGetAttribute() method seems to stall up, preventing the for loop in GetExtensionMethods() from concluding. Simply having FlowGraphExtensions.AppendTypeReflectionNodesMenu() not get extension methods lets the menu load from my end.
When wrapping the RTGetAttribute() method into a try/catch, this is the exception I get:
Message:
GetPackageByAssetPath can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.Stack:
at (wrapper managed-to-native) UnityEditor.PackageManager.PackageInfo.GetPackageByAssetPath(string)
at UnityEditor.PackageManager.PackageInfo.FindForAssetPath (System.String assetPath) [0x0001b] in <12f9706bdb064a6c8a1d1b6f565a0097>:0
at UnityEditor.PackageManager.PackageInfo.FindForAssembly (System.Reflection.Assembly assembly) [0x00032] in <12f9706bdb064a6c8a1d1b6f565a0097>:0
at UnityEngine.Rendering.DocumentationInfo.get_version () [0x00000] in C:\Users\leona\Documents\Projects\FlowCanvasTest2021\Library\PackageCache\com.unity.render-pipelines.core@12.1.0\Runtime\Documentation.cs:52
at UnityEngine.Rendering.DocumentationInfo.GetPageLink (System.String packageName, System.String pageName) [0x00000] in C:\Users\leona\Documents\Projects\FlowCanvasTest2021\Library\PackageCache\com.unity.render-pipelines.core@12.1.0\Runtime\Documentation.cs:66
at UnityEngine.Rendering.CoreRPHelpURLAttribute..ctor (System.String pageName, System.String packageName) [0x00000] in C:\Users\leona\Documents\Projects\FlowCanvasTest2021\Library\PackageCache\com.unity.render-pipelines.core@12.1.0\Runtime\Documentation.cs:30
at UnityEngine.Rendering.HighDefinition.HDRPHelpURLAttribute..ctor (System.String pageName) [0x00000] in C:\Users\leona\Documents\Projects\FlowCanvasTest2021\Library\PackageCache\com.unity.render-pipelines.high-definition@12.1.0\Runtime\Documentation.cs:9
at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesInternal(System.Reflection.ICustomAttributeProvider,System.Type,bool)
at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00013] in <7b5f9a2f7db343a4ab54846ed680277b>:0
at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00037] in <7b5f9a2f7db343a4ab54846ed680277b>:0
at System.RuntimeType.GetCustomAttributes (System.Boolean inherit) [0x00000] in <7b5f9a2f7db343a4ab54846ed680277b>:0
at ParadoxNotion.ReflectionTools.RTGetAllAttributes (System.Type type) [0x0000f] in C:\Users\leona\Documents\Projects\FlowCanvasTest2021\Assets\ParadoxNotion\CanvasCore\Common\Runtime\ReflectionTools.cs:877
at ParadoxNotion.ReflectionTools.RTGetAttribute (System.Type type, System.Type attributeType, System.Boolean inherited) [0x00000] in C:\Users\leona\Documents\Projects\FlowCanvasTest2021\Assets\ParadoxNotion\CanvasCore\Common\Runtime\ReflectionTools.cs:894
Hello and thank you for the details.
I just tried a project in HDRP Unity 2021.2.0xx and I had no problems with the menu loading. Can you please let me know whether or not you have added any custom types in the Preferred Types Editor and if so does resetting it to the default types avoids the issue? It could be that some of the custom types added to the list are the cause of this.
Having said that, putting the call in a silent try-catch block can also be a quick fix.
Please let me know regarding the preferred types list.
Thank you!
Join us on Discord: https://discord.gg/97q2Rjh
On my main project, there are custom types added in, but in the above example of creating a new project using Unity’s 2021 “3D Sample Scene (HDRP)” template, I didn’t add or change anything to get the stalled Add Nodes menu.
My fix for now has been to wrap ReflectionTools.RTGetAttribute<T>() (at line 874) in a try/catch and that’s gotten us past this blocker.
Thank you for the reply. I will probably do the same for the time being until a better solution is found.
Join us on Discord: https://discord.gg/97q2Rjh
Hello and good day.
The issue persist at 3.2.2 on unity 2021.2.1f1, but in this case you have to open it twice to see the content on the pop menu, so here is a simply question, if I need to add a new type, which are the rules to have it without affect it?.
Greetings
From the inimaginable and beyond, where the mind feels free.
Hello and sorry for the late reply!
Can you please post for me here the types which you have added in the Preferred Types Editor?
I want to double-check a few things in regards to what could be wrong.
Thank you!
Join us on Discord: https://discord.gg/97q2Rjh