Forum

Hotswapping clears data

hello hello,

I have an application in which I’m caching lots of data from a web API in different dictionaries when the patch starts. those dictionaries are Dictionary<String,T>, where T is a custom Record.

if I start manipulating the definition of one of those records (moving a pin, a pad, creating an operation), all my dictionaries are erased. sometimes, only the Dictionary containing instances of the Record I’m touching is erased, sometimes all of them.

I made a simple repro patch that shows this behavior, see this gif :

cache

so here you can see that when I’m adding an operation to T, the Dictionary<String,T> is cleared. this behavior seems random because in some cases, just moving a pin or a pad clears the dict, sometimes only one dict is affected, sometimes all the dicts are.

i tried to travel back in time to see when this starts happening and noticed two things :

  • this behavior does not seem to occur on 2021.3. tested 2021.3.0 and 2021.3.3 and did not see this issue. 2021.4.0 (which is the one on which this gif was recorded) shows this behavior
  • when opening my test patch in 2021.3, some nodes have their input reset to default value. this is a screenshot from the CacheStuff patch on 2021.4.0 :

image

and the same portion opened on 2021.3 :

image

so here’s the patch, happy to provide more details or more tests if necessary.

Repro.vl (31.3 KB)

merci beaucoup beaucoup

If your change affects the signature of the patch, the affected instances will be discared and NOT reloaded. A signature change is adding/removing a pin, adding/removing an operation, adding/removing an interface etc. anything that changes the patch from an outside persepective. So for example adding a node, drawing a link, changing a value usually has no effect on the signature. This behavior was indeed introduced with 2021.4.0

From the changelog of 2021.4.1 we can read

No longer generate proxy classes for records - they shall be as lightweight as possible. The reasoning is that we don’t patch inside of records that often. Since they usually pop up as leaves inside of object graphs, the performance impact of the proxy indirection layer can be quite severe.

This change was probably a little bit too harsh, it means that any change inside of a record will not be reloaded but instead the instance will be discarded. We decided to step back on this a little and do so only for records stemming from libraries. In upcoming previews user defined records should behave the same way as they did in 2021.4.0 again - modifications to a record will lead to a reload of all affected instances as long as the signature of the record wasn’t changed.

Hope this sheds some light on the issue.

3 Likes