dataFromJson/dataToJson vs onAdd/onSave

hi all,

can someone explain to me quickly what’s the differences between the common dataFromJson/dataToJson method for load/save data versus the new ones onAdd/onSave?

for example on WTVCO: it could be written on dataFromJson/dataToJson resulting the same, isn’t?

manual says its for avoid UI lagging, but aren’t those methods called on the same UI thread?

thanks for any clarification

1 Like

Off the top of my head I’d say the main difference is that onAdd is called when a module is added to the rack also from the browser and dataFromJson obviously only makes sense when loading an existing patch. Also onSave and dataToJson are called repeatedly on each autosave (iirc every 30s?).

I guess except for my first point it’s mostly usage difference, onAdd and onSave are generic for the module and the Json counterparts are for the current state or state to be loaded.

One would have to double check but I think all 4 functions run on the engine thread, not the ui. Also, the order of execution would be interesting to have in the docs for sure.

1 Like

True. However, that’s the same for the CTOR of the Module, which is called when you create the module; but maybe at that point some values (as folders path) are not yet loaded. Make sense, thanks!

On manual they refers to “UI lagging” using those methods, that’s why I think UI thread. Engine thread shouldn’t impact UI. Also, Engine and Audio are different correct? (otherwise, storing patch would introduce glitch on audio if they are processed both on engine thread).