Dynamic variables "leak" into wrong space when multiple equally named `DynamicVariableSpace` components are duplicated together
Describe the bug?
When you duplicate a hierarchy of multiple nested identically named DynamicVariableSpace components, any variables that are directly bound to them will "leak" from the highest dynamic variable space into the other ones. This only happens to named spaces and variables that are directly bound (so prefixed by the space name).
To Reproduce
Create two nested slots, each with a DynamicVariableSpace with the same name, give each a directly bound variable with the same name, but separate values, and duplicate them both together. You'll notice that the value from the parent dynamic variable space will override the value of the child dynamic variable space.
Note how using either DynamicVariableSpace components without a name or indirectly bound variables will behave as expected.
Expected behavior
The two distinct spaces will maintain distinct values in the duplicated hierarchy.
Screenshots
Resonite Version Number
Beta 2024.10.29.1229
What Platforms does this occur on?
Windows
What headset if any do you use?
Valve Index
Log Files
J4-C - 2024.10.29.1229 - 2024-10-31 19_57_13.log
Additional Context
I ran into this after putting a lot of work into designing a data structure for a project I'm currently working on. Without this being addressed I won't be able to implement the system I've designed properly.
Reporters
Myself
After glancing at the inner workings I suspect the following chain of events:
inner.CurrentNameandouter.CurrentNameare null.outer.OnDuplicateis called.outer.CurrentNameis updated.outer.RelinkAllVariablesis called.- Variables within
outerare linked toouter. - Variables within
innerskipinnerbecause its CurrentName is still null. - Variables within
innerlink withouterdue to matching name. innervariables will be overwritten with the values from theoutervariables.
This does sound like it is likely an order of operations issue. From the documentation on the wiki:
"The process of a dynamic variable being associated with a given space is called binding. A dynamic variable component will traverse up the slot hierarchy, including its current slot, looking for an applicable variable space to bind to. If a dynamic variable does not find a dynamic variable space that it can bind to, it will not be accessible outside of the component itself, essentially reducing to a glorified ValueField. A dynamic variable will go through this binding process every time any part of the component changes."
Based on the description of the binding process- it does sound like it should identify / find the child space prior to the parent in this context.
This issue appears to also be part of the underlying problem reported in #3140
Based on the description of the binding process- it does sound like it should identify / find the child space prior to the parent in this context.
chiming in to say that I wrote the wiki page without knowledge of this edge case. that description of what happens just felt the most intuitive sense to describe. but yeah, given how it's inconsistent with indirect binding/null spaces, definitely feels like a bug
Yeah this is definitely not behaving as it should. It's probably a simple fix, but this bug is currently blocking a big chunk of work I planned to do for the Cloudscape Harvest update, so I'm hoping this can get looked into and addressed some time soon-ish.
Also currently blocking work on the Systems Standard I have been working on: https://wiki.resonite.com/User:Mint_Shock/System_Standard
I could likely somehow work around this bug but that would require a lot of workarounds and would make the Setup a lot less simple and deprecated once this gets fixed.