Every once in a while myself as well as users in the Discord encounter a situation where the node menu seems to get stuck on the “loading” screen seemingly at random. The progress bar never advances; closing and re-opening the node menu doesn’t work. The only solution is to force Unity to reload/unload (by changing some source code) or simply restarting Unity.
Today it happened to me several times and I finally managed to track it, or at least he instance I was experiencing, down to a thread deadlock that happens infrequently. Two threads were manipulating the same Dictionary object inside of ReflectionTools, and since TryGetvalue isn’t thread-safe, they deadlocked each other. I used the thread inspector in my IDE to determine where the problem occurred and worked backward from there with some Googling.
I resolved it by replacing all Dictionary objects in ReflectionTools.cs with ConcurrentDictionary, which _is_ thread-safe. After that, I couldn’t reproduce the problem anymore.
I also made this modification to ensure that any known threads were aborted when the node window was closed, since I encountered an exception from inside Unity that didn’t cause the thread abort code to close.
(see screenshot since forum keeps mangling code)
Thanks a lot for looking into this. ConcurrentDictionary seems like a good solution. I will investigate this further to only change the dictionaries that might be accessed concurrently. Also thanks for the change in GenericMenu. That seems to fix the weird log (even though harmless) that was poping from time to time 🙂