Resonite-Issues icon indicating copy to clipboard operation
Resonite-Issues copied to clipboard

Dynamic variables "leak" into wrong space when multiple equally named `DynamicVariableSpace` components are duplicated together

Open JackTheFoxOtter opened this issue 1 year ago • 6 comments

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

Image Image

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

JackTheFoxOtter avatar Oct 31 '24 19:10 JackTheFoxOtter

After glancing at the inner workings I suspect the following chain of events:

  1. inner.CurrentName and outer.CurrentName are null.
  2. outer.OnDuplicate is called.
  3. outer.CurrentName is updated.
  4. outer.RelinkAllVariables is called.
  5. Variables within outer are linked to outer.
  6. Variables within inner skip inner because its CurrentName is still null.
  7. Variables within inner link with outer due to matching name.
  8. inner variables will be overwritten with the values from the outer variables.

mpmxyz avatar Oct 31 '24 19:10 mpmxyz

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.

LexiBasilisk avatar Oct 31 '24 23:10 LexiBasilisk

This issue appears to also be part of the underlying problem reported in #3140

JackTheFoxOtter avatar Nov 01 '24 15:11 JackTheFoxOtter

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

yoshiyoshyosh avatar Dec 19 '24 17:12 yoshiyoshyosh

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.

JackTheFoxOtter avatar Dec 19 '24 19:12 JackTheFoxOtter

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.

Mint-Shock avatar Nov 21 '25 23:11 Mint-Shock